From: Matt Corallo Date: Fri, 28 Jul 2023 23:27:07 +0000 (+0000) Subject: Update auto-generated bindings to LDK 0.0.116 X-Git-Tag: v0.0.116.0^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=7ebc93258c70a014e9129c0b464256d2ee670751;p=ldk-c-bindings Update auto-generated bindings to LDK 0.0.116 --- diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index dd6a43c..5e75a71 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -14,40 +14,23 @@ struct nativeRefundOpaque; typedef struct nativeRefundOpaque LDKnativeRefund; struct nativeRecipientOnionFieldsOpaque; typedef struct nativeRecipientOnionFieldsOpaque LDKnativeRecipientOnionFields; -struct nativeCounterpartyCommitmentSecretsOpaque; -typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; -struct nativeTxCreationKeysOpaque; -typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys; -struct nativeChannelPublicKeysOpaque; -typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys; -struct nativeHTLCOutputInCommitmentOpaque; -typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment; -struct nativeChannelTransactionParametersOpaque; -typedef struct nativeChannelTransactionParametersOpaque LDKnativeChannelTransactionParameters; -struct nativeCounterpartyChannelTransactionParametersOpaque; -typedef struct nativeCounterpartyChannelTransactionParametersOpaque LDKnativeCounterpartyChannelTransactionParameters; -struct nativeDirectedChannelTransactionParametersOpaque; -typedef struct nativeDirectedChannelTransactionParametersOpaque LDKnativeDirectedChannelTransactionParameters; -struct nativeHolderCommitmentTransactionOpaque; -typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction; -struct nativeBuiltCommitmentTransactionOpaque; -typedef struct nativeBuiltCommitmentTransactionOpaque LDKnativeBuiltCommitmentTransaction; -struct nativeClosingTransactionOpaque; -typedef struct nativeClosingTransactionOpaque LDKnativeClosingTransaction; -struct nativeTrustedClosingTransactionOpaque; -typedef struct nativeTrustedClosingTransactionOpaque LDKnativeTrustedClosingTransaction; -struct nativeCommitmentTransactionOpaque; -typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction; -struct nativeTrustedCommitmentTransactionOpaque; -typedef struct nativeTrustedCommitmentTransactionOpaque LDKnativeTrustedCommitmentTransaction; -struct nativeShutdownScriptOpaque; -typedef struct nativeShutdownScriptOpaque LDKnativeShutdownScript; -struct nativeInvalidShutdownScriptOpaque; -typedef struct nativeInvalidShutdownScriptOpaque LDKnativeInvalidShutdownScript; -struct nativeUnsignedInvoiceOpaque; -typedef struct nativeUnsignedInvoiceOpaque LDKnativeUnsignedInvoice; +struct nativeUnsignedBolt12InvoiceOpaque; +typedef struct nativeUnsignedBolt12InvoiceOpaque LDKnativeUnsignedBolt12Invoice; +struct nativeBolt12InvoiceOpaque; +typedef struct nativeBolt12InvoiceOpaque LDKnativeBolt12Invoice; struct nativeBlindedPayInfoOpaque; typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; +struct nativeDelayedPaymentOutputDescriptorOpaque; +typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; +struct nativeStaticPaymentOutputDescriptorOpaque; +typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor; +struct LDKChannelSigner; +struct nativeInMemorySignerOpaque; +typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; +struct nativeKeysManagerOpaque; +typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; +struct nativePhantomKeysManagerOpaque; +typedef struct nativePhantomKeysManagerOpaque LDKnativePhantomKeysManager; struct nativeBackgroundProcessorOpaque; typedef struct nativeBackgroundProcessorOpaque LDKnativeBackgroundProcessor; struct nativeDefaultRouterOpaque; @@ -72,10 +55,6 @@ struct nativeRouteHintOpaque; typedef struct nativeRouteHintOpaque LDKnativeRouteHint; struct nativeRouteHintHopOpaque; typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop; -struct nativeBestBlockOpaque; -typedef struct nativeBestBlockOpaque LDKnativeBestBlock; -struct nativeWatchedOutputOpaque; -typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; struct nativeMultiThreadedLockableScoreOpaque; typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore; struct nativeMultiThreadedScoreLockOpaque; @@ -86,16 +65,22 @@ struct nativeFixedPenaltyScorerOpaque; typedef struct nativeFixedPenaltyScorerOpaque LDKnativeFixedPenaltyScorer; struct nativeProbabilisticScorerOpaque; typedef struct nativeProbabilisticScorerOpaque LDKnativeProbabilisticScorer; -struct nativeProbabilisticScoringParametersOpaque; -typedef struct nativeProbabilisticScoringParametersOpaque LDKnativeProbabilisticScoringParameters; +struct nativeProbabilisticScoringFeeParametersOpaque; +typedef struct nativeProbabilisticScoringFeeParametersOpaque LDKnativeProbabilisticScoringFeeParameters; +struct nativeProbabilisticScoringDecayParametersOpaque; +typedef struct nativeProbabilisticScoringDecayParametersOpaque LDKnativeProbabilisticScoringDecayParameters; +struct nativeBestBlockOpaque; +typedef struct nativeBestBlockOpaque LDKnativeBestBlock; +struct nativeWatchedOutputOpaque; +typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; struct nativeInitFeaturesOpaque; typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; struct nativeNodeFeaturesOpaque; typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; struct nativeChannelFeaturesOpaque; typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; -struct nativeInvoiceFeaturesOpaque; -typedef struct nativeInvoiceFeaturesOpaque LDKnativeInvoiceFeatures; +struct nativeBolt11InvoiceFeaturesOpaque; +typedef struct nativeBolt11InvoiceFeaturesOpaque LDKnativeBolt11InvoiceFeatures; struct nativeOfferFeaturesOpaque; typedef struct nativeOfferFeaturesOpaque LDKnativeOfferFeatures; struct nativeInvoiceRequestFeaturesOpaque; @@ -134,19 +119,22 @@ struct nativeNodeAliasOpaque; typedef struct nativeNodeAliasOpaque LDKnativeNodeAlias; struct nativeNodeInfoOpaque; typedef struct nativeNodeInfoOpaque LDKnativeNodeInfo; -struct nativeDelayedPaymentOutputDescriptorOpaque; -typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; -struct nativeStaticPaymentOutputDescriptorOpaque; -typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor; -struct LDKChannelSigner; -struct nativeInMemorySignerOpaque; -typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; -struct nativeKeysManagerOpaque; -typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; -struct nativePhantomKeysManagerOpaque; -typedef struct nativePhantomKeysManagerOpaque LDKnativePhantomKeysManager; -struct nativeFilesystemPersisterOpaque; -typedef struct nativeFilesystemPersisterOpaque LDKnativeFilesystemPersister; +struct nativeChannelDerivationParametersOpaque; +typedef struct nativeChannelDerivationParametersOpaque LDKnativeChannelDerivationParameters; +struct nativeAnchorDescriptorOpaque; +typedef struct nativeAnchorDescriptorOpaque LDKnativeAnchorDescriptor; +struct nativeHTLCDescriptorOpaque; +typedef struct nativeHTLCDescriptorOpaque LDKnativeHTLCDescriptor; +struct nativeInputOpaque; +typedef struct nativeInputOpaque LDKnativeInput; +struct nativeUtxoOpaque; +typedef struct nativeUtxoOpaque LDKnativeUtxo; +struct nativeCoinSelectionOpaque; +typedef struct nativeCoinSelectionOpaque LDKnativeCoinSelection; +struct nativeWalletOpaque; +typedef struct nativeWalletOpaque LDKnativeWallet; +struct nativeBumpTransactionEventHandlerOpaque; +typedef struct nativeBumpTransactionEventHandlerOpaque LDKnativeBumpTransactionEventHandler; struct nativeChannelManagerOpaque; typedef struct nativeChannelManagerOpaque LDKnativeChannelManager; struct nativeChainParametersOpaque; @@ -167,18 +155,10 @@ struct nativeChannelHandshakeLimitsOpaque; typedef struct nativeChannelHandshakeLimitsOpaque LDKnativeChannelHandshakeLimits; struct nativeChannelConfigOpaque; typedef struct nativeChannelConfigOpaque LDKnativeChannelConfig; +struct nativeChannelConfigUpdateOpaque; +typedef struct nativeChannelConfigUpdateOpaque LDKnativeChannelConfigUpdate; struct nativeUserConfigOpaque; typedef struct nativeUserConfigOpaque LDKnativeUserConfig; -struct nativeBigSizeOpaque; -typedef struct nativeBigSizeOpaque LDKnativeBigSize; -struct nativeHostnameOpaque; -typedef struct nativeHostnameOpaque LDKnativeHostname; -struct nativeUntrustedStringOpaque; -typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; -struct nativePrintableStringOpaque; -typedef struct nativePrintableStringOpaque LDKnativePrintableString; -struct nativeOutPointOpaque; -typedef struct nativeOutPointOpaque LDKnativeOutPoint; struct nativeChannelMonitorUpdateOpaque; typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate; struct nativeHTLCUpdateOpaque; @@ -197,38 +177,12 @@ struct nativePeerHandleErrorOpaque; typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError; struct nativePeerManagerOpaque; typedef struct nativePeerManagerOpaque LDKnativePeerManager; -struct nativeUtxoFutureOpaque; -typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture; -struct nativeOnionMessengerOpaque; -typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger; -struct nativeBlindedPathOpaque; -typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; -struct nativeBlindedHopOpaque; -typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; -struct nativeInvoiceOpaque; -typedef struct nativeInvoiceOpaque LDKnativeInvoice; -struct nativeSignedRawInvoiceOpaque; -typedef struct nativeSignedRawInvoiceOpaque LDKnativeSignedRawInvoice; -struct nativeRawInvoiceOpaque; -typedef struct nativeRawInvoiceOpaque LDKnativeRawInvoice; -struct nativeRawDataPartOpaque; -typedef struct nativeRawDataPartOpaque LDKnativeRawDataPart; -struct nativePositiveTimestampOpaque; -typedef struct nativePositiveTimestampOpaque LDKnativePositiveTimestamp; -struct nativeSha256Opaque; -typedef struct nativeSha256Opaque LDKnativeSha256; -struct nativeDescriptionOpaque; -typedef struct nativeDescriptionOpaque LDKnativeDescription; -struct nativePayeePubKeyOpaque; -typedef struct nativePayeePubKeyOpaque LDKnativePayeePubKey; -struct nativeExpiryTimeOpaque; -typedef struct nativeExpiryTimeOpaque LDKnativeExpiryTime; -struct nativeMinFinalCltvExpiryDeltaOpaque; -typedef struct nativeMinFinalCltvExpiryDeltaOpaque LDKnativeMinFinalCltvExpiryDelta; -struct nativeInvoiceSignatureOpaque; -typedef struct nativeInvoiceSignatureOpaque LDKnativeInvoiceSignature; -struct nativePrivateRouteOpaque; -typedef struct nativePrivateRouteOpaque LDKnativePrivateRoute; +struct nativeRapidGossipSyncOpaque; +typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; +struct nativeUnsignedInvoiceRequestOpaque; +typedef struct nativeUnsignedInvoiceRequestOpaque LDKnativeUnsignedInvoiceRequest; +struct nativeInvoiceRequestOpaque; +typedef struct nativeInvoiceRequestOpaque LDKnativeInvoiceRequest; struct nativeInitOpaque; typedef struct nativeInitOpaque LDKnativeInit; struct nativeErrorMessageOpaque; @@ -241,14 +195,36 @@ struct nativePongOpaque; typedef struct nativePongOpaque LDKnativePong; struct nativeOpenChannelOpaque; typedef struct nativeOpenChannelOpaque LDKnativeOpenChannel; +struct nativeOpenChannelV2Opaque; +typedef struct nativeOpenChannelV2Opaque LDKnativeOpenChannelV2; struct nativeAcceptChannelOpaque; typedef struct nativeAcceptChannelOpaque LDKnativeAcceptChannel; +struct nativeAcceptChannelV2Opaque; +typedef struct nativeAcceptChannelV2Opaque LDKnativeAcceptChannelV2; struct nativeFundingCreatedOpaque; typedef struct nativeFundingCreatedOpaque LDKnativeFundingCreated; struct nativeFundingSignedOpaque; typedef struct nativeFundingSignedOpaque LDKnativeFundingSigned; struct nativeChannelReadyOpaque; typedef struct nativeChannelReadyOpaque LDKnativeChannelReady; +struct nativeTxAddInputOpaque; +typedef struct nativeTxAddInputOpaque LDKnativeTxAddInput; +struct nativeTxAddOutputOpaque; +typedef struct nativeTxAddOutputOpaque LDKnativeTxAddOutput; +struct nativeTxRemoveInputOpaque; +typedef struct nativeTxRemoveInputOpaque LDKnativeTxRemoveInput; +struct nativeTxRemoveOutputOpaque; +typedef struct nativeTxRemoveOutputOpaque LDKnativeTxRemoveOutput; +struct nativeTxCompleteOpaque; +typedef struct nativeTxCompleteOpaque LDKnativeTxComplete; +struct nativeTxSignaturesOpaque; +typedef struct nativeTxSignaturesOpaque LDKnativeTxSignatures; +struct nativeTxInitRbfOpaque; +typedef struct nativeTxInitRbfOpaque LDKnativeTxInitRbf; +struct nativeTxAckRbfOpaque; +typedef struct nativeTxAckRbfOpaque LDKnativeTxAckRbf; +struct nativeTxAbortOpaque; +typedef struct nativeTxAbortOpaque LDKnativeTxAbort; struct nativeShutdownOpaque; typedef struct nativeShutdownOpaque LDKnativeShutdown; struct nativeClosingSignedFeeRangeOpaque; @@ -271,8 +247,6 @@ struct nativeRevokeAndACKOpaque; typedef struct nativeRevokeAndACKOpaque LDKnativeRevokeAndACK; struct nativeUpdateFeeOpaque; typedef struct nativeUpdateFeeOpaque LDKnativeUpdateFee; -struct nativeDataLossProtectOpaque; -typedef struct nativeDataLossProtectOpaque LDKnativeDataLossProtect; struct nativeChannelReestablishOpaque; typedef struct nativeChannelReestablishOpaque LDKnativeChannelReestablish; struct nativeAnnouncementSignaturesOpaque; @@ -303,21 +277,101 @@ struct nativeLightningErrorOpaque; typedef struct nativeLightningErrorOpaque LDKnativeLightningError; struct nativeCommitmentUpdateOpaque; typedef struct nativeCommitmentUpdateOpaque LDKnativeCommitmentUpdate; -struct nativeUnsignedInvoiceRequestOpaque; -typedef struct nativeUnsignedInvoiceRequestOpaque LDKnativeUnsignedInvoiceRequest; -struct nativeInvoiceRequestOpaque; -typedef struct nativeInvoiceRequestOpaque LDKnativeInvoiceRequest; struct nativeRecordOpaque; typedef struct nativeRecordOpaque LDKnativeRecord; struct nativeFutureOpaque; typedef struct nativeFutureOpaque LDKnativeFuture; struct nativeSleeperOpaque; typedef struct nativeSleeperOpaque LDKnativeSleeper; +struct nativeCounterpartyCommitmentSecretsOpaque; +typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; +struct nativeTxCreationKeysOpaque; +typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys; +struct nativeChannelPublicKeysOpaque; +typedef struct nativeChannelPublicKeysOpaque LDKnativeChannelPublicKeys; +struct nativeHTLCOutputInCommitmentOpaque; +typedef struct nativeHTLCOutputInCommitmentOpaque LDKnativeHTLCOutputInCommitment; +struct nativeChannelTransactionParametersOpaque; +typedef struct nativeChannelTransactionParametersOpaque LDKnativeChannelTransactionParameters; +struct nativeCounterpartyChannelTransactionParametersOpaque; +typedef struct nativeCounterpartyChannelTransactionParametersOpaque LDKnativeCounterpartyChannelTransactionParameters; +struct nativeDirectedChannelTransactionParametersOpaque; +typedef struct nativeDirectedChannelTransactionParametersOpaque LDKnativeDirectedChannelTransactionParameters; +struct nativeHolderCommitmentTransactionOpaque; +typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction; +struct nativeBuiltCommitmentTransactionOpaque; +typedef struct nativeBuiltCommitmentTransactionOpaque LDKnativeBuiltCommitmentTransaction; +struct nativeClosingTransactionOpaque; +typedef struct nativeClosingTransactionOpaque LDKnativeClosingTransaction; +struct nativeTrustedClosingTransactionOpaque; +typedef struct nativeTrustedClosingTransactionOpaque LDKnativeTrustedClosingTransaction; +struct nativeCommitmentTransactionOpaque; +typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction; +struct nativeTrustedCommitmentTransactionOpaque; +typedef struct nativeTrustedCommitmentTransactionOpaque LDKnativeTrustedCommitmentTransaction; +struct nativeShutdownScriptOpaque; +typedef struct nativeShutdownScriptOpaque LDKnativeShutdownScript; +struct nativeInvalidShutdownScriptOpaque; +typedef struct nativeInvalidShutdownScriptOpaque LDKnativeInvalidShutdownScript; +struct nativeBolt12ParseErrorOpaque; +typedef struct nativeBolt12ParseErrorOpaque LDKnativeBolt12ParseError; +struct nativeFilesystemPersisterOpaque; +typedef struct nativeFilesystemPersisterOpaque LDKnativeFilesystemPersister; +struct nativeBolt11InvoiceOpaque; +typedef struct nativeBolt11InvoiceOpaque LDKnativeBolt11Invoice; +struct nativeSignedRawBolt11InvoiceOpaque; +typedef struct nativeSignedRawBolt11InvoiceOpaque LDKnativeSignedRawBolt11Invoice; +struct nativeRawBolt11InvoiceOpaque; +typedef struct nativeRawBolt11InvoiceOpaque LDKnativeRawBolt11Invoice; +struct nativeRawDataPartOpaque; +typedef struct nativeRawDataPartOpaque LDKnativeRawDataPart; +struct nativePositiveTimestampOpaque; +typedef struct nativePositiveTimestampOpaque LDKnativePositiveTimestamp; +struct nativeSha256Opaque; +typedef struct nativeSha256Opaque LDKnativeSha256; +struct nativeDescriptionOpaque; +typedef struct nativeDescriptionOpaque LDKnativeDescription; +struct nativePayeePubKeyOpaque; +typedef struct nativePayeePubKeyOpaque LDKnativePayeePubKey; +struct nativeExpiryTimeOpaque; +typedef struct nativeExpiryTimeOpaque LDKnativeExpiryTime; +struct nativeMinFinalCltvExpiryDeltaOpaque; +typedef struct nativeMinFinalCltvExpiryDeltaOpaque LDKnativeMinFinalCltvExpiryDelta; +struct nativeBolt11InvoiceSignatureOpaque; +typedef struct nativeBolt11InvoiceSignatureOpaque LDKnativeBolt11InvoiceSignature; +struct nativePrivateRouteOpaque; +typedef struct nativePrivateRouteOpaque LDKnativePrivateRoute; +struct nativeOutPointOpaque; +typedef struct nativeOutPointOpaque LDKnativeOutPoint; +struct nativeBigSizeOpaque; +typedef struct nativeBigSizeOpaque LDKnativeBigSize; +struct nativeHostnameOpaque; +typedef struct nativeHostnameOpaque LDKnativeHostname; +struct nativeTransactionU16LenLimitedOpaque; +typedef struct nativeTransactionU16LenLimitedOpaque LDKnativeTransactionU16LenLimited; +struct nativeUntrustedStringOpaque; +typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; +struct nativePrintableStringOpaque; +typedef struct nativePrintableStringOpaque LDKnativePrintableString; +struct nativeUtxoFutureOpaque; +typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture; +struct nativeOnionMessengerOpaque; +typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger; +struct nativeDefaultMessageRouterOpaque; +typedef struct nativeDefaultMessageRouterOpaque LDKnativeDefaultMessageRouter; +struct nativeOnionMessagePathOpaque; +typedef struct nativeOnionMessagePathOpaque LDKnativeOnionMessagePath; +struct nativeBlindedPathOpaque; +typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; +struct nativeBlindedHopOpaque; +typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; +struct nativeInvoiceErrorOpaque; +typedef struct nativeInvoiceErrorOpaque LDKnativeInvoiceError; +struct nativeErroneousFieldOpaque; +typedef struct nativeErroneousFieldOpaque LDKnativeErroneousField; struct nativeMonitorUpdateIdOpaque; typedef struct nativeMonitorUpdateIdOpaque LDKnativeMonitorUpdateId; struct nativeLockedChannelMonitorOpaque; typedef struct nativeLockedChannelMonitorOpaque LDKnativeLockedChannelMonitor; struct nativeChainMonitorOpaque; typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; -struct nativeRapidGossipSyncOpaque; -typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index cbbe93e..bf4f3dd 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -10,6 +10,172 @@ #include #include "ldk_rust_types.h" +/** + * Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to + * the requirements sections in BOLT #11 + */ +typedef enum LDKBolt11SemanticError { + /** + * The invoice is missing the mandatory payment hash + */ + LDKBolt11SemanticError_NoPaymentHash, + /** + * The invoice has multiple payment hashes which isn't allowed + */ + LDKBolt11SemanticError_MultiplePaymentHashes, + /** + * No description or description hash are part of the invoice + */ + LDKBolt11SemanticError_NoDescription, + /** + * The invoice contains multiple descriptions and/or description hashes which isn't allowed + */ + LDKBolt11SemanticError_MultipleDescriptions, + /** + * The invoice is missing the mandatory payment secret, which all modern lightning nodes + * should provide. + */ + LDKBolt11SemanticError_NoPaymentSecret, + /** + * The invoice contains multiple payment secrets + */ + LDKBolt11SemanticError_MultiplePaymentSecrets, + /** + * The invoice's features are invalid + */ + LDKBolt11SemanticError_InvalidFeatures, + /** + * The recovery id doesn't fit the signature/pub key + */ + LDKBolt11SemanticError_InvalidRecoveryId, + /** + * The invoice's signature is invalid + */ + LDKBolt11SemanticError_InvalidSignature, + /** + * The invoice's amount was not a whole number of millisatoshis + */ + LDKBolt11SemanticError_ImpreciseAmount, + /** + * Must be last for serialization purposes + */ + LDKBolt11SemanticError_Sentinel, +} LDKBolt11SemanticError; + +/** + * Error when interpreting a TLV stream as a specific type. + */ +typedef enum LDKBolt12SemanticError { + /** + * The current [`std::time::SystemTime`] is past the offer or invoice's expiration. + */ + LDKBolt12SemanticError_AlreadyExpired, + /** + * The provided chain hash does not correspond to a supported chain. + */ + LDKBolt12SemanticError_UnsupportedChain, + /** + * A chain was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedChain, + /** + * An amount was expected but was missing. + */ + LDKBolt12SemanticError_MissingAmount, + /** + * The amount exceeded the total bitcoin supply. + */ + LDKBolt12SemanticError_InvalidAmount, + /** + * An amount was provided but was not sufficient in value. + */ + LDKBolt12SemanticError_InsufficientAmount, + /** + * An amount was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedAmount, + /** + * A currency was provided that is not supported. + */ + LDKBolt12SemanticError_UnsupportedCurrency, + /** + * A feature was required but is unknown. + */ + LDKBolt12SemanticError_UnknownRequiredFeatures, + /** + * Features were provided but were not expected. + */ + LDKBolt12SemanticError_UnexpectedFeatures, + /** + * A required description was not provided. + */ + LDKBolt12SemanticError_MissingDescription, + /** + * A signing pubkey was not provided. + */ + LDKBolt12SemanticError_MissingSigningPubkey, + /** + * A signing pubkey was provided but a different one was expected. + */ + LDKBolt12SemanticError_InvalidSigningPubkey, + /** + * A signing pubkey was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedSigningPubkey, + /** + * A quantity was expected but was missing. + */ + LDKBolt12SemanticError_MissingQuantity, + /** + * An unsupported quantity was provided. + */ + LDKBolt12SemanticError_InvalidQuantity, + /** + * A quantity or quantity bounds was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedQuantity, + /** + * Metadata could not be used to verify the offers message. + */ + LDKBolt12SemanticError_InvalidMetadata, + /** + * Metadata was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedMetadata, + /** + * Payer metadata was expected but was missing. + */ + LDKBolt12SemanticError_MissingPayerMetadata, + /** + * A payer id was expected but was missing. + */ + LDKBolt12SemanticError_MissingPayerId, + /** + * Blinded paths were expected but were missing. + */ + LDKBolt12SemanticError_MissingPaths, + /** + * The blinded payinfo given does not match the number of blinded path hops. + */ + LDKBolt12SemanticError_InvalidPayInfo, + /** + * An invoice creation time was expected but was missing. + */ + LDKBolt12SemanticError_MissingCreationTime, + /** + * An invoice payment hash was expected but was missing. + */ + LDKBolt12SemanticError_MissingPaymentHash, + /** + * A signature was expected but was missing. + */ + LDKBolt12SemanticError_MissingSignature, + /** + * Must be last for serialization purposes + */ + LDKBolt12SemanticError_Sentinel, +} LDKBolt12SemanticError; + /** * An enum which can either contain a or not */ @@ -118,20 +284,68 @@ typedef enum LDKChannelMonitorUpdateStatus { } LDKChannelMonitorUpdateStatus; /** - * An enum that represents the speed at which we want a transaction to confirm used for feerate + * Further information on the details of the channel shutdown. + * Upon channels being forced closed (i.e. commitment transaction confirmation detected + * by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or + * the channel will be removed shortly. + * Also note, that in normal operation, peers could disconnect at any of these states + * and require peer re-connection before making progress onto other states + */ +typedef enum LDKChannelShutdownState { + /** + * Channel has not sent or received a shutdown message. + */ + LDKChannelShutdownState_NotShuttingDown, + /** + * Local node has sent a shutdown message for this channel. + */ + LDKChannelShutdownState_ShutdownInitiated, + /** + * Shutdown message exchanges have concluded and the channels are in the midst of + * resolving all existing open HTLCs before closing can continue. + */ + LDKChannelShutdownState_ResolvingHTLCs, + /** + * All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. + */ + LDKChannelShutdownState_NegotiatingClosingFee, + /** + * We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about + * to drop the channel. + */ + LDKChannelShutdownState_ShutdownComplete, + /** + * Must be last for serialization purposes + */ + LDKChannelShutdownState_Sentinel, +} LDKChannelShutdownState; + +/** + * An enum that represents the priority at which we want a transaction to confirm used for feerate * estimation. */ typedef enum LDKConfirmationTarget { /** - * We are happy with this transaction confirming slowly when feerate drops some. + * We'd like a transaction to confirm in the future, but don't want to commit most of the fees + * required to do so yet. The remaining fees will come via a Child-Pays-For-Parent (CPFP) fee + * bump of the transaction. + * + * The feerate returned should be the absolute minimum feerate required to enter most node + * mempools across the network. Note that if you are not able to obtain this feerate estimate, + * you should likely use the furthest-out estimate allowed by your fee estimator. + */ + LDKConfirmationTarget_MempoolMinimum, + /** + * We are happy with a transaction confirming slowly, at least within a day or so worth of + * blocks. */ LDKConfirmationTarget_Background, /** - * We'd like this transaction to confirm without major delay, but 12-18 blocks is fine. + * We'd like a transaction to confirm without major delayed, i.e., within the next 12-24 blocks. */ LDKConfirmationTarget_Normal, /** - * We'd like this transaction to confirm in the next few blocks. + * We'd like a transaction to confirm in the next few blocks. */ LDKConfirmationTarget_HighPriority, /** @@ -141,7 +355,7 @@ typedef enum LDKConfirmationTarget { } LDKConfirmationTarget; /** - * Errors that may occur when constructing a new [`RawInvoice`] or [`Invoice`] + * Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] */ typedef enum LDKCreationError { /** @@ -515,58 +729,6 @@ typedef enum LDKSecp256k1Error { LDKSecp256k1Error_Sentinel, } LDKSecp256k1Error; -/** - * Errors that may occur when converting a [`RawInvoice`] to an [`Invoice`]. They relate to the - * requirements sections in BOLT #11 - */ -typedef enum LDKSemanticError { - /** - * The invoice is missing the mandatory payment hash - */ - LDKSemanticError_NoPaymentHash, - /** - * The invoice has multiple payment hashes which isn't allowed - */ - LDKSemanticError_MultiplePaymentHashes, - /** - * No description or description hash are part of the invoice - */ - LDKSemanticError_NoDescription, - /** - * The invoice contains multiple descriptions and/or description hashes which isn't allowed - */ - LDKSemanticError_MultipleDescriptions, - /** - * The invoice is missing the mandatory payment secret, which all modern lightning nodes - * should provide. - */ - LDKSemanticError_NoPaymentSecret, - /** - * The invoice contains multiple payment secrets - */ - LDKSemanticError_MultiplePaymentSecrets, - /** - * The invoice's features are invalid - */ - LDKSemanticError_InvalidFeatures, - /** - * The recovery id doesn't fit the signature/pub key - */ - LDKSemanticError_InvalidRecoveryId, - /** - * The invoice's signature is invalid - */ - LDKSemanticError_InvalidSignature, - /** - * The invoice's amount was not a whole number of millisatoshis - */ - LDKSemanticError_ImpreciseAmount, - /** - * Must be last for serialization purposes - */ - LDKSemanticError_Sentinel, -} LDKSemanticError; - /** * SI prefixes for the human readable part */ @@ -792,6 +954,36 @@ typedef struct LDKCVec_u8Z { uintptr_t datalen; } LDKCVec_u8Z; +/** + * An input to a transaction. + * + * This contains the witness, the scriptSig and the previous outpoint and represents a single + * input to a transaction + */ +typedef struct LDKTxIn { + /** + * The witness which includes any signatures required to spend a segwit output. + */ + struct LDKWitness witness; + /** + * The script_sig which includes signatures requires to spend a pre-segwit output (or a + * P2SH-wrapped segwit output). + */ + struct LDKCVec_u8Z script_sig; + /** + * The sequence number of the transaction input + */ + uint32_t sequence; + /** + * The txid of the transaction being spent. + */ + struct LDKThirtyTwoBytes previous_txid; + /** + * The output index of the transaction being spent. + */ + uint32_t previous_vout; +} LDKTxIn; + /** * A transaction output including a scriptPubKey and value. * This type *does* own its own memory, so must be free'd appropriately. @@ -900,6 +1092,86 @@ typedef struct LDKCOption_u64Z { +/** + * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`]. + * + * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to + * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a + * bitcoin ATM. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Offer`]: crate::offers::offer::Offer + */ +typedef struct MUST_USE_STRUCT LDKRefund { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRefund *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRefund; + + + +/** + * Error when parsing a bech32 encoded message using [`str::parse`]. + */ +typedef struct MUST_USE_STRUCT LDKBolt12ParseError { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt12ParseError *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt12ParseError; + +/** + * The contents of CResult_RefundBolt12ParseErrorZ + */ +typedef union LDKCResult_RefundBolt12ParseErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRefund *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKBolt12ParseError *err; +} LDKCResult_RefundBolt12ParseErrorZPtr; + +/** + * A CResult_RefundBolt12ParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RefundBolt12ParseErrorZ { + /** + * The contents of this CResult_RefundBolt12ParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RefundBolt12ParseErrorZPtr contents; + /** + * Whether this CResult_RefundBolt12ParseErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RefundBolt12ParseErrorZ; + + + /** * A script pubkey for shutting down a channel as defined by [BOLT #2]. * @@ -965,7 +1237,7 @@ typedef enum LDKAPIError_Tag { * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open * a channel or cooperatively close one with this peer (and will have to force-close instead). * - * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey * [`InitFeatures`]: crate::ln::features::InitFeatures */ LDKAPIError_IncompatibleShutdownScript, @@ -1089,6 +1361,33 @@ typedef struct LDKCVec_APIErrorZ { uintptr_t datalen; } LDKCVec_APIErrorZ; +/** + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not + */ +typedef enum LDKCOption_PaymentSecretZ_Tag { + /** + * When we're in this state, this COption_PaymentSecretZ contains a crate::c_types::ThirtyTwoBytes + */ + LDKCOption_PaymentSecretZ_Some, + /** + * When we're in this state, this COption_PaymentSecretZ contains nothing + */ + LDKCOption_PaymentSecretZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PaymentSecretZ_Sentinel, +} LDKCOption_PaymentSecretZ_Tag; + +typedef struct LDKCOption_PaymentSecretZ { + LDKCOption_PaymentSecretZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_PaymentSecretZ; + /** * An enum which can either contain a crate::c_types::derived::CVec_u8Z or not */ @@ -1225,426 +1524,482 @@ typedef struct LDKCResult_RecipientOnionFieldsDecodeErrorZ { bool result_ok; } LDKCResult_RecipientOnionFieldsDecodeErrorZ; + + /** - * An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not + * Information needed to route a payment across a [`BlindedPath`]. */ -typedef enum LDKCOption_HTLCClaimZ_Tag { - /** - * When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim - */ - LDKCOption_HTLCClaimZ_Some, +typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { /** - * When we're in this state, this COption_HTLCClaimZ contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_HTLCClaimZ_None, + LDKnativeBlindedPayInfo *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_HTLCClaimZ_Sentinel, -} LDKCOption_HTLCClaimZ_Tag; - -typedef struct LDKCOption_HTLCClaimZ { - LDKCOption_HTLCClaimZ_Tag tag; - union { - struct { - enum LDKHTLCClaim some; - }; - }; -} LDKCOption_HTLCClaimZ; + bool is_owned; +} LDKBlindedPayInfo; /** - * The contents of CResult_NoneNoneZ + * The contents of CResult_BlindedPayInfoDecodeErrorZ */ -typedef union LDKCResult_NoneNoneZPtr { +typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKBlindedPayInfo *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_NoneNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_BlindedPayInfoDecodeErrorZPtr; /** - * A CResult_NoneNoneZ represents the result of a fallible operation, - * containing a () on success and a () on failure. + * A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneNoneZ { +typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { /** - * The contents of this CResult_NoneNoneZ, accessible via either + * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneNoneZPtr contents; + union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; /** - * Whether this CResult_NoneNoneZ represents a success state. + * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneNoneZ; +} LDKCResult_BlindedPayInfoDecodeErrorZ; /** - * Implements the per-commitment secret storage scheme from - * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). + * Information about a spendable output to a P2WSH script. * - * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes - * or so. + * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { +typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCounterpartyCommitmentSecrets *inner; + LDKnativeDelayedPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCounterpartyCommitmentSecrets; +} LDKDelayedPaymentOutputDescriptor; /** - * The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ + * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCounterpartyCommitmentSecrets *result; + struct LDKDelayedPaymentOutputDescriptor *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr; +} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr; /** - * A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ { +typedef struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either + * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr contents; + union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. + * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ; +} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ; /** - * The set of public keys which are used in the creation of one commitment transaction. - * These are derived from the channel base keys and per-commitment data. - * - * A broadcaster key is provided from potential broadcaster of the computed transaction. - * A countersignatory key is coming from a protocol participant unable to broadcast the - * transaction. + * Information about a spendable output to our \"payment key\". * - * These keys are assumed to be good, either because the code derived them from - * channel basepoints via the new function, or they were obtained via - * CommitmentTransaction.trust().keys() because we trusted the source of the - * pre-calculated keys. + * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKTxCreationKeys { +typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeTxCreationKeys *inner; + LDKnativeStaticPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKTxCreationKeys; +} LDKStaticPaymentOutputDescriptor; /** - * The contents of CResult_TxCreationKeysDecodeErrorZ + * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_TxCreationKeysDecodeErrorZPtr { +typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTxCreationKeys *result; + struct LDKStaticPaymentOutputDescriptor *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_TxCreationKeysDecodeErrorZPtr; +} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr; /** - * A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TxCreationKeysDecodeErrorZ { +typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either + * The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TxCreationKeysDecodeErrorZPtr contents; + union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. + * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TxCreationKeysDecodeErrorZ; +} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ; /** - * One counterparty's public keys which do not change over the life of a channel. + * A reference to a transaction output. + * + * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 + * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. */ -typedef struct MUST_USE_STRUCT LDKChannelPublicKeys { +typedef struct MUST_USE_STRUCT LDKOutPoint { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelPublicKeys *inner; + LDKnativeOutPoint *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelPublicKeys; +} LDKOutPoint; /** - * The contents of CResult_ChannelPublicKeysDecodeErrorZ + * Describes the necessary information to spend a spendable output. + * + * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any + * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able + * to spend on-chain. The information needed to do this is provided in this enum, including the + * outpoint describing which `txid` and output `index` is available, the full output which exists + * at that `txid`/`index`, and any keys or other information required to sign. + * + * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs */ -typedef union LDKCResult_ChannelPublicKeysDecodeErrorZPtr { +typedef enum LDKSpendableOutputDescriptor_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An output to a script which was provided via [`SignerProvider`] directly, either from + * [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already + * know how to spend it. No secret keys are provided as LDK was never given any key. + * These may include outputs from a transaction punishing our counterparty or claiming an HTLC + * on-chain using the payment preimage or after it has timed out. + * + * [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey + * [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey */ - struct LDKChannelPublicKeys *result; + LDKSpendableOutputDescriptor_StaticOutput, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` + * delay. + * + * The witness in the spending input should be: + * ```bitcoin + * (MINIMALIF standard rule) + * ``` + * + * Note that the `nSequence` field in the spending input must be set to + * [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not + * broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after + * the outpoint confirms, see [BIP + * 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK + * won't generate a [`SpendableOutputDescriptor`] until the corresponding block height + * is reached. + * + * These are generally the result of a \"revocable\" output to us, spendable only by us unless + * it is an output from an old state which we broadcast (which should never happen). + * + * To derive the delayed payment key which is used to sign this input, you must pass the + * holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the + * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided + * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be + * generated without the secret key using [`chan_utils::derive_public_key`] and only the + * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. + * + * To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is + * used in the witness script generation), you must pass the counterparty + * [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to + * [`ChannelSigner::provide_channel_parameters`]) and the provided + * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to + * [`chan_utils::derive_public_revocation_key`]. + * + * The witness script which is hashed and included in the output `script_pubkey` may be + * regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived + * as explained above), our delayed payment pubkey (derived as explained above), and the + * [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to + * [`chan_utils::get_revokeable_redeemscript`]. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelPublicKeysDecodeErrorZPtr; - -/** - * A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelPublicKeysDecodeErrorZ { + LDKSpendableOutputDescriptor_DelayedPaymentOutput, /** - * The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key + * which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness + * in the spending input is, thus, simply: + * ```bitcoin + * + * ``` + * + * These are generally the result of our counterparty having broadcast the current state, + * allowing us to claim the non-HTLC-encumbered outputs immediately. */ - union LDKCResult_ChannelPublicKeysDecodeErrorZPtr contents; + LDKSpendableOutputDescriptor_StaticPaymentOutput, /** - * Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_ChannelPublicKeysDecodeErrorZ; + LDKSpendableOutputDescriptor_Sentinel, +} LDKSpendableOutputDescriptor_Tag; -/** - * An enum which can either contain a u32 or not - */ -typedef enum LDKCOption_u32Z_Tag { - /** - * When we're in this state, this COption_u32Z contains a u32 - */ - LDKCOption_u32Z_Some, +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { /** - * When we're in this state, this COption_u32Z contains nothing + * The outpoint which is spendable. */ - LDKCOption_u32Z_None, + struct LDKOutPoint outpoint; /** - * Must be last for serialization purposes + * The output which is referenced by the given outpoint. */ - LDKCOption_u32Z_Sentinel, -} LDKCOption_u32Z_Tag; + struct LDKTxOut output; +} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; -typedef struct LDKCOption_u32Z { - LDKCOption_u32Z_Tag tag; +typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { + LDKSpendableOutputDescriptor_Tag tag; union { + LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; struct { - uint32_t some; + struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; + }; + struct { + struct LDKStaticPaymentOutputDescriptor static_payment_output; }; }; -} LDKCOption_u32Z; - - - -/** - * Information about an HTLC as it appears in a commitment transaction - */ -typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeHTLCOutputInCommitment *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKHTLCOutputInCommitment; +} LDKSpendableOutputDescriptor; /** - * The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ + * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ */ -typedef union LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr { +typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKHTLCOutputInCommitment *result; + struct LDKSpendableOutputDescriptor *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; /** - * A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ { +typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { /** - * The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either + * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr contents; + union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; /** - * Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. + * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_HTLCOutputInCommitmentDecodeErrorZ; +} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning::sign::SpendableOutputDescriptors of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_SpendableOutputDescriptorZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKSpendableOutputDescriptor *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_SpendableOutputDescriptorZ; + +/** + * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TxOutZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKTxOut *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_TxOutZ; +/** + * An enum which can either contain a u32 or not + */ +typedef enum LDKCOption_PackedLockTimeZ_Tag { + /** + * When we're in this state, this COption_PackedLockTimeZ contains a u32 + */ + LDKCOption_PackedLockTimeZ_Some, + /** + * When we're in this state, this COption_PackedLockTimeZ contains nothing + */ + LDKCOption_PackedLockTimeZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PackedLockTimeZ_Sentinel, +} LDKCOption_PackedLockTimeZ_Tag; +typedef struct LDKCOption_PackedLockTimeZ { + LDKCOption_PackedLockTimeZ_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} LDKCOption_PackedLockTimeZ; /** - * Late-bound per-channel counterparty data used to build transactions. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKCounterpartyChannelTransactionParameters { +typedef struct LDKC2Tuple_PartiallySignedTransactionusizeZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeCounterpartyChannelTransactionParameters *inner; + struct LDKCVec_u8Z a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKCounterpartyChannelTransactionParameters; + uintptr_t b; +} LDKC2Tuple_PartiallySignedTransactionusizeZ; /** - * The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ + * The contents of CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ */ -typedef union LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { +typedef union LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCounterpartyChannelTransactionParameters *result; + struct LDKC2Tuple_PartiallySignedTransactionusizeZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr; + void *err; +} LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr; /** - * A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { /** - * The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr contents; /** - * Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ; - - +} LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ; /** - * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). - * The fields are organized by holder/counterparty. - * - * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters - * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { +typedef struct LDKCVec_PaymentPreimageZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChannelTransactionParameters *inner; + struct LDKThirtyTwoBytes *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChannelTransactionParameters; + uintptr_t datalen; +} LDKCVec_PaymentPreimageZ; /** - * The contents of CResult_ChannelTransactionParametersDecodeErrorZ + * The contents of CResult_NoneNoneZ */ -typedef union LDKCResult_ChannelTransactionParametersDecodeErrorZPtr { +typedef union LDKCResult_NoneNoneZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKChannelTransactionParameters *result; + void *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_ChannelTransactionParametersDecodeErrorZPtr; + void *err; +} LDKCResult_NoneNoneZPtr; /** - * A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NoneNoneZ represents the result of a fallible operation, + * containing a () on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelTransactionParametersDecodeErrorZ { +typedef struct LDKCResult_NoneNoneZ { /** - * The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either + * The contents of this CResult_NoneNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelTransactionParametersDecodeErrorZPtr contents; + union LDKCResult_NoneNoneZPtr contents; /** - * Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. + * Whether this CResult_NoneNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelTransactionParametersDecodeErrorZ; +} LDKCResult_NoneNoneZ; /** * Represents a secp256k1 signature serialized as two 32-byte numbers @@ -1672,170 +2027,251 @@ typedef struct LDKCVec_SignatureZ { uintptr_t datalen; } LDKCVec_SignatureZ; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { + /** + * The element at position 0 + */ + struct LDKSignature a; + /** + * The element at position 1 + */ + struct LDKCVec_SignatureZ b; +} LDKC2Tuple_SignatureCVec_SignatureZZ; +/** + * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ + */ +typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; /** - * Information needed to build and sign a holder's commitment transaction. - * - * The transaction is only signed once we are ready to broadcast. + * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { +typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeHolderCommitmentTransaction *inner; + union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. */ - bool is_owned; -} LDKHolderCommitmentTransaction; + bool result_ok; +} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; /** - * The contents of CResult_HolderCommitmentTransactionDecodeErrorZ + * The contents of CResult_SignatureNoneZ */ -typedef union LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr { +typedef union LDKCResult_SignatureNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKHolderCommitmentTransaction *result; + struct LDKSignature *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr; + void *err; +} LDKCResult_SignatureNoneZPtr; /** - * A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Signature on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ { +typedef struct LDKCResult_SignatureNoneZ { /** - * The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either + * The contents of this CResult_SignatureNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr contents; + union LDKCResult_SignatureNoneZPtr contents; /** - * Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. + * Whether this CResult_SignatureNoneZ represents a success state. */ bool result_ok; -} LDKCResult_HolderCommitmentTransactionDecodeErrorZ; +} LDKCResult_SignatureNoneZ; + +/** + * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. + */ +typedef struct LDKPublicKey { + /** + * The bytes of the public key + */ + uint8_t compressed_form[33]; +} LDKPublicKey; +/** + * The contents of CResult_PublicKeyNoneZ + */ +typedef union LDKCResult_PublicKeyNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKPublicKey *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_PublicKeyNoneZPtr; +/** + * A CResult_PublicKeyNoneZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PublicKeyNoneZ { + /** + * The contents of this CResult_PublicKeyNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PublicKeyNoneZPtr contents; + /** + * Whether this CResult_PublicKeyNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_PublicKeyNoneZ; /** - * A pre-built Bitcoin commitment transaction and its txid. + * An enum which can either contain a crate::c_types::BigEndianScalar or not */ -typedef struct MUST_USE_STRUCT LDKBuiltCommitmentTransaction { +typedef enum LDKCOption_ScalarZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar */ - LDKnativeBuiltCommitmentTransaction *inner; + LDKCOption_ScalarZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_ScalarZ contains nothing */ - bool is_owned; -} LDKBuiltCommitmentTransaction; + LDKCOption_ScalarZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ScalarZ_Sentinel, +} LDKCOption_ScalarZ_Tag; + +typedef struct LDKCOption_ScalarZ { + LDKCOption_ScalarZ_Tag tag; + union { + struct { + struct LDKBigEndianScalar some; + }; + }; +} LDKCOption_ScalarZ; /** - * The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ + * The contents of CResult_SharedSecretNoneZ */ -typedef union LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr { +typedef union LDKCResult_SharedSecretNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBuiltCommitmentTransaction *result; + struct LDKThirtyTwoBytes *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr; + void *err; +} LDKCResult_SharedSecretNoneZPtr; /** - * A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SharedSecretNoneZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ { +typedef struct LDKCResult_SharedSecretNoneZ { /** - * The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either + * The contents of this CResult_SharedSecretNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr contents; + union LDKCResult_SharedSecretNoneZPtr contents; /** - * Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. + * Whether this CResult_SharedSecretNoneZ represents a success state. */ bool result_ok; -} LDKCResult_BuiltCommitmentTransactionDecodeErrorZ; - +} LDKCResult_SharedSecretNoneZ; +/** + * Integer in the range `0..32` + */ +typedef struct LDKU5 { + uint8_t _0; +} LDKU5; /** - * A wrapper on ClosingTransaction indicating that the built bitcoin - * transaction is trusted. - * - * See trust() and verify() functions on CommitmentTransaction. - * - * This structure implements Deref. + * A dynamically-allocated array of crate::c_types::U5s of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKTrustedClosingTransaction { +typedef struct LDKCVec_U5Z { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeTrustedClosingTransaction *inner; + struct LDKU5 *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKTrustedClosingTransaction; + uintptr_t datalen; +} LDKCVec_U5Z; /** - * The contents of CResult_TrustedClosingTransactionNoneZ + * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which + * allows recovering the exact public key which created the signature given the message. */ -typedef union LDKCResult_TrustedClosingTransactionNoneZPtr { +typedef struct LDKRecoverableSignature { + /** + * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for + * recovery. + */ + uint8_t serialized_form[68]; +} LDKRecoverableSignature; + +/** + * The contents of CResult_RecoverableSignatureNoneZ + */ +typedef union LDKCResult_RecoverableSignatureNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTrustedClosingTransaction *result; + struct LDKRecoverableSignature *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_TrustedClosingTransactionNoneZPtr; +} LDKCResult_RecoverableSignatureNoneZPtr; /** - * A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. + * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::RecoverableSignature on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TrustedClosingTransactionNoneZ { +typedef struct LDKCResult_RecoverableSignatureNoneZ { /** - * The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either + * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TrustedClosingTransactionNoneZPtr contents; + union LDKCResult_RecoverableSignatureNoneZPtr contents; /** - * Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. + * Whether this CResult_RecoverableSignatureNoneZ represents a success state. */ bool result_ok; -} LDKCResult_TrustedClosingTransactionNoneZ; +} LDKCResult_RecoverableSignatureNoneZ; @@ -1862,266 +2298,689 @@ typedef struct MUST_USE_STRUCT LDKCommitmentTransaction { bool is_owned; } LDKCommitmentTransaction; + + /** - * The contents of CResult_CommitmentTransactionDecodeErrorZ + * Information needed to build and sign a holder's commitment transaction. + * + * The transaction is only signed once we are ready to broadcast. */ -typedef union LDKCResult_CommitmentTransactionDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKCommitmentTransaction *result; + LDKnativeHolderCommitmentTransaction *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_CommitmentTransactionDecodeErrorZPtr; + bool is_owned; +} LDKHolderCommitmentTransaction; + + /** - * A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Information about an HTLC as it appears in a commitment transaction */ -typedef struct LDKCResult_CommitmentTransactionDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment { /** - * The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_CommitmentTransactionDecodeErrorZPtr contents; + LDKnativeHTLCOutputInCommitment *inner; /** - * Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_CommitmentTransactionDecodeErrorZ; + bool is_owned; +} LDKHTLCOutputInCommitment; /** - * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin - * transaction and the transaction creation keys) are trusted. - * - * See trust() and verify() functions on CommitmentTransaction. - * - * This structure implements Deref. + * A descriptor used to sign for a commitment transaction's HTLC output. */ -typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction { +typedef struct MUST_USE_STRUCT LDKHTLCDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeTrustedCommitmentTransaction *inner; + LDKnativeHTLCDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKTrustedCommitmentTransaction; +} LDKHTLCDescriptor; + + /** - * The contents of CResult_TrustedCommitmentTransactionNoneZ + * This class tracks the per-transaction information needed to build a closing transaction and will + * actually build it and sign. + * + * This class can be used inside a signer implementation to generate a signature given the relevant + * secret key. */ -typedef union LDKCResult_TrustedCommitmentTransactionNoneZPtr { +typedef struct MUST_USE_STRUCT LDKClosingTransaction { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKTrustedCommitmentTransaction *result; + LDKnativeClosingTransaction *inner; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void *err; -} LDKCResult_TrustedCommitmentTransactionNoneZPtr; + bool is_owned; +} LDKClosingTransaction; + + /** - * A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, - * containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * The unsigned part of a [`channel_announcement`] message. + * + * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message */ -typedef struct LDKCResult_TrustedCommitmentTransactionNoneZ { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { /** - * The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_TrustedCommitmentTransactionNoneZPtr contents; + LDKnativeUnsignedChannelAnnouncement *inner; /** - * Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedChannelAnnouncement; + + + +/** + * One counterparty's public keys which do not change over the life of a channel. + */ +typedef struct MUST_USE_STRUCT LDKChannelPublicKeys { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelPublicKeys *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelPublicKeys; + + + +/** + * Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). + * The fields are organized by holder/counterparty. + * + * Normally, this is converted to the broadcaster/countersignatory-organized DirectedChannelTransactionParameters + * before use, via the as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelTransactionParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelTransactionParameters; + +/** + * A trait to handle Lightning channel key material without concretizing the channel type or + * the signature mechanism. + */ +typedef struct LDKChannelSigner { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the per-commitment point for a specific commitment number + * + * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + */ + struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + /** + * Gets the commitment secret for a specific commitment number as part of the revocation process + * + * An external signer implementation should error here if the commitment was already signed + * and should refuse to sign it in the future. + * + * May be called more than once for the same index. + * + * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + */ + struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + /** + * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + * + * This is required in order for the signer to make sure that releasing a commitment + * secret won't leave us without a broadcastable holder transaction. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * Note that all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. + */ + struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); + /** + * Returns the holder's channel public keys and basepoints. + */ + struct LDKChannelPublicKeys pubkeys; + /** + * Fill in the pubkeys field as a reference to it will be given to Rust after this returns + * Note that this takes a pointer to this object, not the this_ptr like other methods do + * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. + */ + void (*set_pubkeys)(const struct LDKChannelSigner*NONNULL_PTR ); + /** + * Returns an arbitrary identifier describing the set of keys which are provided back to you in + * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this + * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. + */ + struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); + /** + * Set the counterparty static channel data, including basepoints, + * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. + * + * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] + * instance, LDK will call this method exactly once - either immediately after construction + * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding + * information has been generated. + * + * channel_parameters.is_populated() MUST be true. + */ + void (*provide_channel_parameters)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKChannelSigner; + +/** + * A trait to sign Lightning channel transactions as described in + * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). + * + * Signing services could be implemented on a hardware wallet and should implement signing + * policies in order to be secure. Please refer to the [VLS Policy + * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) + * for an example of such policies. + */ +typedef struct LDKEcdsaChannelSigner { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. + * + * Note that if signing fails or is rejected, the channel will be force-closed. + * + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * Note that all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. + */ + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); + /** + * Validate the counterparty's revocation. + * + * This is required in order for the signer to make sure that the state has moved + * forward and it is safe to sign the next counterparty commitment. + */ + struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]); + /** + * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. + * + * This will be called + * - with a non-revoked `commitment_tx`. + * - with the latest `commitment_tx` when we initiate a force-close. + * - with the previous `commitment_tx`, just to get claiming HTLC + * signatures, if we are reacting to a [`ChannelMonitor`] + * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) + * that decided to broadcast before it had been updated to the latest `commitment_tx`. + * + * This may be called multiple times for the same transaction. + * + * An external signer implementation should check that the commitment has not been revoked. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + */ + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); + /** + * Create a signature for the given input in a transaction spending an HTLC transaction output + * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. + * + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. + * + * Amount is value of the output spent by this input, committed to in the BIP 143 signature. + * + * `per_commitment_key` is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do + * so). + */ + struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); + /** + * Create a signature for the given input in a transaction spending a commitment transaction + * HTLC output when our counterparty broadcasts an old state. + * + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. + * + * `amount` is the value of the output spent by this input, committed to in the BIP 143 + * signature. + * + * `per_commitment_key` is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder revocation_secret to do + * so). + * + * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script + * (which is committed to in the BIP 143 signatures). + */ + struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + /** + * Computes the signature for a commitment transaction's HTLC output used as an input within + * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned + * must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to + * sign HTLC transactions from channels supporting anchor outputs after all additional + * inputs/outputs have been added to the transaction. + * + * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All + */ + struct LDKCResult_SignatureNoneZ (*sign_holder_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, const struct LDKHTLCDescriptor *NONNULL_PTR htlc_descriptor); + /** + * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment + * transaction, either offered or received. + * + * Such a transaction may claim multiples offered outputs at same time if we know the + * preimage for each when we create it, but only the input at index `input` should be + * signed for here. It may be called multiple times for same output(s) if a fee-bump is + * needed with regards to an upcoming timelock expiration. + * + * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC + * outputs. + * + * `amount` is value of the output spent by this input, committed to in the BIP 143 signature. + * + * `per_commitment_point` is the dynamic point corresponding to the channel state + * detected onchain. It has been generated by our counterparty and is used to derive + * channel state keys, which are then included in the witness script and committed to in the + * BIP 143 signature. + */ + struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + /** + * Create a signature for a (proposed) closing transaction. + * + * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have + * chosen to forgo their output as dust. + */ + struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); + /** + * Computes the signature for a commitment transaction's anchor output used as an + * input within `anchor_tx`, which spends the commitment transaction, at index `input`. + */ + struct LDKCResult_SignatureNoneZ (*sign_holder_anchor_input)(const void *this_arg, struct LDKTransaction anchor_tx, uintptr_t input); + /** + * Signs a channel announcement message with our funding key proving it comes from one of the + * channel participants. + * + * Channel announcements also require a signature from each node's network key. Our node + * signature is computed through [`NodeSigner::sign_gossip_message`]. + * + * Note that if this fails or is rejected, the channel will not be publicly announced and + * our counterparty may (though likely will not) close the channel on us for violating the + * protocol. + */ + struct LDKCResult_SignatureNoneZ (*sign_channel_announcement_with_funding_key)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + /** + * Implementation of ChannelSigner for this object. + */ + struct LDKChannelSigner ChannelSigner; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEcdsaChannelSigner; + +/** + * A writeable signer. + * + * There will always be two instances of a signer per channel, one occupied by the + * [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + */ +typedef struct LDKWriteableEcdsaChannelSigner { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Implementation of EcdsaChannelSigner for this object. + */ + struct LDKEcdsaChannelSigner EcdsaChannelSigner; + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWriteableEcdsaChannelSigner; + +/** + * The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ + */ +typedef union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKWriteableEcdsaChannelSigner *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr; + +/** + * A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ { + /** + * The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr contents; + /** + * Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TrustedCommitmentTransactionNoneZ; +} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ; /** - * The contents of CResult_CVec_SignatureZNoneZ + * The contents of CResult_ScriptNoneZ */ -typedef union LDKCResult_CVec_SignatureZNoneZPtr { +typedef union LDKCResult_ScriptNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_SignatureZ *result; + struct LDKCVec_u8Z *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_CVec_SignatureZNoneZPtr; +} LDKCResult_ScriptNoneZPtr; /** - * A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. + * A CResult_ScriptNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_SignatureZNoneZ { +typedef struct LDKCResult_ScriptNoneZ { /** - * The contents of this CResult_CVec_SignatureZNoneZ, accessible via either + * The contents of this CResult_ScriptNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_SignatureZNoneZPtr contents; + union LDKCResult_ScriptNoneZPtr contents; /** - * Whether this CResult_CVec_SignatureZNoneZ represents a success state. + * Whether this CResult_ScriptNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_SignatureZNoneZ; +} LDKCResult_ScriptNoneZ; /** - * The contents of CResult_ShutdownScriptDecodeErrorZ + * The contents of CResult_ShutdownScriptNoneZ */ -typedef union LDKCResult_ShutdownScriptDecodeErrorZPtr { +typedef union LDKCResult_ShutdownScriptNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ struct LDKShutdownScript *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_ShutdownScriptDecodeErrorZPtr; + void *err; +} LDKCResult_ShutdownScriptNoneZPtr; /** - * A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ShutdownScriptNoneZ represents the result of a fallible operation, + * containing a crate::lightning::ln::script::ShutdownScript on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownScriptDecodeErrorZ { +typedef struct LDKCResult_ShutdownScriptNoneZ { /** - * The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either + * The contents of this CResult_ShutdownScriptNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownScriptDecodeErrorZPtr contents; + union LDKCResult_ShutdownScriptNoneZPtr contents; /** - * Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. + * Whether this CResult_ShutdownScriptNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownScriptDecodeErrorZ; - - +} LDKCResult_ShutdownScriptNoneZ; /** - * An error occurring when converting from [`Script`] to [`ShutdownScript`]. + * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKInvalidShutdownScript { +typedef struct LDKCVec_CVec_u8ZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeInvalidShutdownScript *inner; + struct LDKCVec_u8Z *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKInvalidShutdownScript; + uintptr_t datalen; +} LDKCVec_CVec_u8ZZ; /** - * The contents of CResult_ShutdownScriptInvalidShutdownScriptZ + * The contents of CResult_CVec_CVec_u8ZZNoneZ */ -typedef union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr { +typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdownScript *result; + struct LDKCVec_CVec_u8ZZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKInvalidShutdownScript *err; -} LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr; + void *err; +} LDKCResult_CVec_CVec_u8ZZNoneZPtr; /** - * A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, - * containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. + * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { +typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { /** - * The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either + * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr contents; + union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; /** - * Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. + * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownScriptInvalidShutdownScriptZ; +} LDKCResult_CVec_CVec_u8ZZNoneZ; /** - * Information needed to route a payment across a [`BlindedPath`]. + * A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. + * + * This implementation performs no policy checks and is insufficient by itself as + * a secure external signer. */ -typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { +typedef struct MUST_USE_STRUCT LDKInMemorySigner { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBlindedPayInfo *inner; + LDKnativeInMemorySigner *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBlindedPayInfo; +} LDKInMemorySigner; /** - * The contents of CResult_BlindedPayInfoDecodeErrorZ + * The contents of CResult_InMemorySignerDecodeErrorZ */ -typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { +typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBlindedPayInfo *result; + struct LDKInMemorySigner *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_BlindedPayInfoDecodeErrorZPtr; +} LDKCResult_InMemorySignerDecodeErrorZPtr; /** - * A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { +typedef struct LDKCResult_InMemorySignerDecodeErrorZ { /** - * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either + * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; + union LDKCResult_InMemorySignerDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPayInfoDecodeErrorZ; +} LDKCResult_InMemorySignerDecodeErrorZ; + +/** + * The contents of CResult_PartiallySignedTransactionNoneZ + */ +typedef union LDKCResult_PartiallySignedTransactionNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCVec_u8Z *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_PartiallySignedTransactionNoneZPtr; + +/** + * A CResult_PartiallySignedTransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PartiallySignedTransactionNoneZ { + /** + * The contents of this CResult_PartiallySignedTransactionNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PartiallySignedTransactionNoneZPtr contents; + /** + * Whether this CResult_PartiallySignedTransactionNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_PartiallySignedTransactionNoneZ; + +/** + * The contents of CResult_TransactionNoneZ + */ +typedef union LDKCResult_TransactionNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKTransaction *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_TransactionNoneZPtr; + +/** + * A CResult_TransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Transaction on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TransactionNoneZ { + /** + * The contents of this CResult_TransactionNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_TransactionNoneZPtr contents; + /** + * Whether this CResult_TransactionNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_TransactionNoneZ; @@ -2166,14 +3025,40 @@ typedef struct MUST_USE_STRUCT LDKChannelUsage { /** - * A path in a [`Route`] to the payment recipient. Must always be at least length one. - * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. - */ -typedef struct MUST_USE_STRUCT LDKPath { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Parameters for configuring [`ProbabilisticScorer`]. + * + * Used to configure base, liquidity, and amount penalties, the sum of which comprises the channel + * penalty (i.e., the amount in msats willing to be paid to avoid routing through the channel). + * + * The penalty applied to any channel by the [`ProbabilisticScorer`] is the sum of each of the + * parameters here. + */ +typedef struct MUST_USE_STRUCT LDKProbabilisticScoringFeeParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeProbabilisticScoringFeeParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKProbabilisticScoringFeeParameters; + + + +/** + * A path in a [`Route`] to the payment recipient. Must always be at least length one. + * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. + */ +typedef struct MUST_USE_STRUCT LDKPath { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ LDKnativePath *inner; /** @@ -2205,7 +3090,7 @@ typedef struct LDKScore { * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. * Thus, implementations should be overflow-safe. */ - uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage); + uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params); /** * Handles updating channel penalties after failing to route through a channel. */ @@ -2605,9 +3490,9 @@ typedef struct LDKCVec_BlindedHopZ { /** * The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in - * their BOLT12 [`Invoice`]. + * their [`Bolt12Invoice`]. * - * [`Invoice`]: crate::offers::invoice::Invoice + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ typedef struct MUST_USE_STRUCT LDKBlindedTail { /** @@ -2673,6 +3558,33 @@ typedef struct LDKCVec_RouteHopZ { uintptr_t datalen; } LDKCVec_RouteHopZ; +/** + * An enum which can either contain a u32 or not + */ +typedef enum LDKCOption_u32Z_Tag { + /** + * When we're in this state, this COption_u32Z contains a u32 + */ + LDKCOption_u32Z_Some, + /** + * When we're in this state, this COption_u32Z contains nothing + */ + LDKCOption_u32Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_u32Z_Sentinel, +} LDKCOption_u32Z_Tag; + +typedef struct LDKCOption_u32Z { + LDKCOption_u32Z_Tag tag; + union { + struct { + uint32_t some; + }; + }; +} LDKCOption_u32Z; + /** * A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. * This corresponds to std::vector in C++ @@ -2727,10 +3639,7 @@ typedef struct LDKCResult_RouteDecodeErrorZ { /** * Parameters needed to find a [`Route`]. * - * Passed to [`find_route`] and [`build_route_from_hops`], but also provided in - * [`Event::PaymentPathFailed`]. - * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * Passed to [`find_route`] and [`build_route_from_hops`]. */ typedef struct MUST_USE_STRUCT LDKRouteParameters { /** @@ -2799,7 +3708,7 @@ typedef struct LDKCVec_u64Z { /** - * The recipient of a payment. + * Information used to route a payment. */ typedef struct MUST_USE_STRUCT LDKPaymentParameters { /** @@ -3017,16 +3926,6 @@ typedef struct LDKCResult_RouteHintHopDecodeErrorZ { bool result_ok; } LDKCResult_RouteHintHopDecodeErrorZ; -/** - * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. - */ -typedef struct LDKPublicKey { - /** - * The bytes of the public key - */ - uint8_t compressed_form[33]; -} LDKPublicKey; - /** * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. * This corresponds to std::vector in C++ @@ -3043,224 +3942,6 @@ typedef struct LDKCVec_PublicKeyZ { uintptr_t datalen; } LDKCVec_PublicKeyZ; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_usizeTransactionZ { - /** - * The element at position 0 - */ - uintptr_t a; - /** - * The element at position 1 - */ - struct LDKTransaction b; -} LDKC2Tuple_usizeTransactionZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_usizeTransactionZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_usizeTransactionZZ; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_TxidBlockHashZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_TxidBlockHashZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_TxidBlockHashZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_TxidBlockHashZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_TxidBlockHashZZ; - - - -/** - * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on - * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the - * preimage claim backward will lead to loss of funds. - */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeHTLCUpdate *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKHTLCUpdate; - - - -/** - * A reference to a transaction output. - * - * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 - * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. - */ -typedef struct MUST_USE_STRUCT LDKOutPoint { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeOutPoint *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKOutPoint; - -/** - * An event to be processed by the ChannelManager. - */ -typedef enum LDKMonitorEvent_Tag { - /** - * A monitor event containing an HTLCUpdate. - */ - LDKMonitorEvent_HTLCEvent, - /** - * A monitor event that the Channel's commitment transaction was confirmed. - */ - LDKMonitorEvent_CommitmentTxConfirmed, - /** - * Indicates a [`ChannelMonitor`] update has completed. See - * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. - * - * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress - */ - LDKMonitorEvent_Completed, - /** - * Indicates a [`ChannelMonitor`] update has failed. See - * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. - * - * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure - */ - LDKMonitorEvent_UpdateFailed, - /** - * Must be last for serialization purposes - */ - LDKMonitorEvent_Sentinel, -} LDKMonitorEvent_Tag; - -typedef struct LDKMonitorEvent_LDKCompleted_Body { - /** - * The funding outpoint of the [`ChannelMonitor`] that was updated - */ - struct LDKOutPoint 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. - */ - uint64_t monitor_update_id; -} LDKMonitorEvent_LDKCompleted_Body; - -typedef struct MUST_USE_STRUCT LDKMonitorEvent { - LDKMonitorEvent_Tag tag; - union { - struct { - struct LDKHTLCUpdate htlc_event; - }; - struct { - struct LDKOutPoint commitment_tx_confirmed; - }; - LDKMonitorEvent_LDKCompleted_Body completed; - struct { - struct LDKOutPoint update_failed; - }; - }; -} LDKMonitorEvent; - -/** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_MonitorEventZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKMonitorEvent *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_MonitorEventZ; - -/** - * A tuple of 3 elements. See the individual fields for the types contained. - */ -typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - /** - * The element at position 0 - */ - struct LDKOutPoint a; - /** - * The element at position 1 - */ - struct LDKCVec_MonitorEventZ b; - /** - * The element at position 2 - */ - struct LDKPublicKey c; -} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; - /** @@ -3314,6 +3995,22 @@ typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { bool result_ok; } LDKCResult_FixedPenaltyScorerDecodeErrorZ; +/** + * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_NodeIdZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKNodeId *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_NodeIdZ; + /** * A tuple of 2 elements. See the individual fields for the types contained. */ @@ -3420,22 +4117,6 @@ typedef struct LDKCOption_C2Tuple_EightU16sEightU16sZZ { }; } LDKCOption_C2Tuple_EightU16sEightU16sZZ; -/** - * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NodeIdZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKNodeId *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_NodeIdZ; - /** @@ -3531,11 +4212,11 @@ typedef struct MUST_USE_STRUCT LDKNetworkGraph { * behavior. * * [1]: https://arxiv.org/abs/2107.05322 - * [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat - * [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life - * [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat - * [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat + * [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_amount_multiplier_msat + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life + * [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_multiplier_msat + * [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_amount_multiplier_msat */ typedef struct MUST_USE_STRUCT LDKProbabilisticScorer { /** @@ -3585,6 +4266,228 @@ typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ { bool result_ok; } LDKCResult_ProbabilisticScorerDecodeErrorZ; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_usizeTransactionZ { + /** + * The element at position 0 + */ + uintptr_t a; + /** + * The element at position 1 + */ + struct LDKTransaction b; +} LDKC2Tuple_usizeTransactionZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_usizeTransactionZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_usizeTransactionZZ; + +/** + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not + */ +typedef enum LDKCOption_BlockHashZ_Tag { + /** + * When we're in this state, this COption_BlockHashZ contains a crate::c_types::ThirtyTwoBytes + */ + LDKCOption_BlockHashZ_Some, + /** + * When we're in this state, this COption_BlockHashZ contains nothing + */ + LDKCOption_BlockHashZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_BlockHashZ_Sentinel, +} LDKCOption_BlockHashZ_Tag; + +typedef struct LDKCOption_BlockHashZ { + LDKCOption_BlockHashZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_BlockHashZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_TxidCOption_BlockHashZZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKCOption_BlockHashZ b; +} LDKC2Tuple_TxidCOption_BlockHashZZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_TxidCOption_BlockHashZZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ; + + + +/** + * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on + * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the + * preimage claim backward will lead to loss of funds. + */ +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeHTLCUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKHTLCUpdate; + +/** + * An event to be processed by the ChannelManager. + */ +typedef enum LDKMonitorEvent_Tag { + /** + * A monitor event containing an HTLCUpdate. + */ + LDKMonitorEvent_HTLCEvent, + /** + * A monitor event that the Channel's commitment transaction was confirmed. + */ + LDKMonitorEvent_CommitmentTxConfirmed, + /** + * Indicates a [`ChannelMonitor`] update has completed. See + * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress + */ + LDKMonitorEvent_Completed, + /** + * Indicates a [`ChannelMonitor`] update has failed. See + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure + */ + LDKMonitorEvent_UpdateFailed, + /** + * Must be last for serialization purposes + */ + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; + +typedef struct LDKMonitorEvent_LDKCompleted_Body { + /** + * The funding outpoint of the [`ChannelMonitor`] that was updated + */ + struct LDKOutPoint 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. + */ + uint64_t monitor_update_id; +} LDKMonitorEvent_LDKCompleted_Body; + +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; + union { + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_confirmed; + }; + LDKMonitorEvent_LDKCompleted_Body completed; + struct { + struct LDKOutPoint update_failed; + }; + }; +} LDKMonitorEvent; + +/** + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_MonitorEventZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKMonitorEvent *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_MonitorEventZ; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + /** + * The element at position 0 + */ + struct LDKOutPoint a; + /** + * The element at position 1 + */ + struct LDKCVec_MonitorEventZ b; + /** + * The element at position 2 + */ + struct LDKPublicKey c; +} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; + /** @@ -3749,53 +4652,106 @@ typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { /** * Features used within an invoice. */ -typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { +typedef struct MUST_USE_STRUCT LDKBolt11InvoiceFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceFeatures *inner; + LDKnativeBolt11InvoiceFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceFeatures; +} LDKBolt11InvoiceFeatures; + +/** + * The contents of CResult_Bolt11InvoiceFeaturesDecodeErrorZ + */ +typedef union LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBolt11InvoiceFeatures *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZPtr; + +/** + * A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ { + /** + * The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZPtr contents; + /** + * Whether this CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ; + + + +/** + * Features used within an `invoice`. + */ +typedef struct MUST_USE_STRUCT LDKBolt12InvoiceFeatures { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt12InvoiceFeatures *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt12InvoiceFeatures; /** - * The contents of CResult_InvoiceFeaturesDecodeErrorZ + * The contents of CResult_Bolt12InvoiceFeaturesDecodeErrorZ */ -typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { +typedef union LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoiceFeatures *result; + struct LDKBolt12InvoiceFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; +} LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZPtr; /** - * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { +typedef struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ { /** - * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_Bolt12InvoiceFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + union LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceFeaturesDecodeErrorZ; +} LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ; @@ -3913,94 +4869,151 @@ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { } LDKCResult_ChannelTypeFeaturesDecodeErrorZ; /** - * Some information provided on receipt of payment depends on whether the payment received is a - * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKPaymentPurpose_Tag { +typedef struct LDKCVec_ChainHashZ { /** - * Information for receiving a payment that we generated an invoice for. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKPaymentPurpose_InvoicePayment, + struct LDKThirtyTwoBytes *data; /** - * Because this is a spontaneous payment, the payer generated their own preimage rather than us - * (the payee) providing a preimage. + * The number of elements pointed to by `data`. */ - LDKPaymentPurpose_SpontaneousPayment, + uintptr_t datalen; +} LDKCVec_ChainHashZ; + + + +/** + * An `Offer` is a potentially long-lived proposal for payment of a good or service. + * + * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a + * customer may request an [`Bolt12Invoice`] for a specific quantity and using an amount sufficient + * to cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. + * + * Offers may be denominated in currency other than bitcoin but are ultimately paid using the + * latter. + * + * Through the use of [`BlindedPath`]s, offers provide recipient privacy. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + */ +typedef struct MUST_USE_STRUCT LDKOffer { /** - * Must be last for serialization purposes + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKPaymentPurpose_Sentinel, -} LDKPaymentPurpose_Tag; + LDKnativeOffer *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOffer; -typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { +/** + * The contents of CResult_OfferBolt12ParseErrorZ + */ +typedef union LDKCResult_OfferBolt12ParseErrorZPtr { /** - * The preimage to the payment_hash, if the payment hash (and secret) were fetched via - * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - * [`ChannelManager::claim_funds`]. - * - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes payment_preimage; + struct LDKOffer *result; /** - * The \"payment secret\". This authenticates the sender to the recipient, preventing a - * number of deanonymization attacks during the routing process. - * It is provided here for your reference, however its accuracy is enforced directly by - * [`ChannelManager`] using the values you previously provided to - * [`ChannelManager::create_inbound_payment`] or - * [`ChannelManager::create_inbound_payment_for_hash`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKThirtyTwoBytes payment_secret; -} LDKPaymentPurpose_LDKInvoicePayment_Body; + struct LDKBolt12ParseError *err; +} LDKCResult_OfferBolt12ParseErrorZPtr; -typedef struct MUST_USE_STRUCT LDKPaymentPurpose { - LDKPaymentPurpose_Tag tag; - union { - LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; - struct { - struct LDKThirtyTwoBytes spontaneous_payment; - }; - }; -} LDKPaymentPurpose; +/** + * A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OfferBolt12ParseErrorZ { + /** + * The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferBolt12ParseErrorZPtr contents; + /** + * Whether this CResult_OfferBolt12ParseErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferBolt12ParseErrorZ; /** - * The contents of CResult_PaymentPurposeDecodeErrorZ + * The contents of CResult_PublicKeyErrorZ */ -typedef union LDKCResult_PaymentPurposeDecodeErrorZPtr { +typedef union LDKCResult_PublicKeyErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPaymentPurpose *result; + struct LDKPublicKey *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKSecp256k1Error *err; +} LDKCResult_PublicKeyErrorZPtr; + +/** + * A CResult_PublicKeyErrorZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PublicKeyErrorZ { + /** + * The contents of this CResult_PublicKeyErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PublicKeyErrorZPtr contents; + /** + * Whether this CResult_PublicKeyErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PublicKeyErrorZ; + +/** + * The contents of CResult_NodeIdDecodeErrorZ + */ +typedef union LDKCResult_NodeIdDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKNodeId *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_PaymentPurposeDecodeErrorZPtr; +} LDKCResult_NodeIdDecodeErrorZPtr; /** - * A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeId on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentPurposeDecodeErrorZ { +typedef struct LDKCResult_NodeIdDecodeErrorZ { /** - * The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either + * The contents of this CResult_NodeIdDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentPurposeDecodeErrorZPtr contents; + union LDKCResult_NodeIdDecodeErrorZPtr contents; /** - * Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. + * Whether this CResult_NodeIdDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentPurposeDecodeErrorZ; +} LDKCResult_NodeIdDecodeErrorZ; @@ -4120,12320 +5133,17293 @@ typedef struct LDKCOption_NetworkUpdateZ { } LDKCOption_NetworkUpdateZ; /** - * When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may - * contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. - * - * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ */ -typedef enum LDKPathFailure_Tag { - /** - * We failed to initially send the payment and no HTLC was committed to. Contains the relevant - * error. - */ - LDKPathFailure_InitialSend, - /** - * A hop on the path failed to forward our payment. - */ - LDKPathFailure_OnPath, - /** - * Must be last for serialization purposes - */ - LDKPathFailure_Sentinel, -} LDKPathFailure_Tag; - -typedef struct LDKPathFailure_LDKInitialSend_Body { +typedef union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr { /** - * The error surfaced from initial send. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAPIError err; -} LDKPathFailure_LDKInitialSend_Body; - -typedef struct LDKPathFailure_LDKOnPath_Body { + struct LDKCOption_NetworkUpdateZ *result; /** - * If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing - * decisions can take into account the update. - * - * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCOption_NetworkUpdateZ network_update; -} LDKPathFailure_LDKOnPath_Body; - -typedef struct MUST_USE_STRUCT LDKPathFailure { - LDKPathFailure_Tag tag; - union { - LDKPathFailure_LDKInitialSend_Body initial_send; - LDKPathFailure_LDKOnPath_Body on_path; - }; -} LDKPathFailure; + struct LDKDecodeError *err; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr; /** - * An enum which can either contain a crate::lightning::events::PathFailure or not + * A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKCOption_PathFailureZ_Tag { - /** - * When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure - */ - LDKCOption_PathFailureZ_Some, +typedef struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ { /** - * When we're in this state, this COption_PathFailureZ contains nothing + * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_PathFailureZ_None, + union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. */ - LDKCOption_PathFailureZ_Sentinel, -} LDKCOption_PathFailureZ_Tag; - -typedef struct LDKCOption_PathFailureZ { - LDKCOption_PathFailureZ_Tag tag; - union { - struct { - struct LDKPathFailure some; - }; - }; -} LDKCOption_PathFailureZ; + bool result_ok; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZ; /** - * The contents of CResult_COption_PathFailureZDecodeErrorZ + * The contents of CResult_TxOutUtxoLookupErrorZ */ -typedef union LDKCResult_COption_PathFailureZDecodeErrorZPtr { +typedef union LDKCResult_TxOutUtxoLookupErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_PathFailureZ *result; + struct LDKTxOut *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_COption_PathFailureZDecodeErrorZPtr; + enum LDKUtxoLookupError *err; +} LDKCResult_TxOutUtxoLookupErrorZPtr; /** - * A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, + * containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_PathFailureZDecodeErrorZ { +typedef struct LDKCResult_TxOutUtxoLookupErrorZ { /** - * The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either + * The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_PathFailureZDecodeErrorZPtr contents; + union LDKCResult_TxOutUtxoLookupErrorZPtr contents; /** - * Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. + * Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_PathFailureZDecodeErrorZ; +} LDKCResult_TxOutUtxoLookupErrorZ; /** - * Struct to `Display` fields in a safe way using `PrintableString` + * Represents a future resolution of a [`UtxoLookup::get_utxo`] query resolving async. + * + * See [`UtxoResult::Async`] and [`UtxoFuture::resolve`] for more info. */ -typedef struct MUST_USE_STRUCT LDKUntrustedString { +typedef struct MUST_USE_STRUCT LDKUtxoFuture { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUntrustedString *inner; + LDKnativeUtxoFuture *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUntrustedString; +} LDKUtxoFuture; /** - * The reason the channel was closed. See individual variants more details. + * The result of a [`UtxoLookup::get_utxo`] call. A call may resolve either synchronously, + * returning the `Sync` variant, or asynchronously, returning an [`UtxoFuture`] in the `Async` + * variant. */ -typedef enum LDKClosureReason_Tag { +typedef enum LDKUtxoResult_Tag { /** - * Closure generated from receiving a peer error message. - * - * Our counterparty may have broadcasted their latest commitment state, and we have - * as well. + * A result which was resolved synchronously. It either includes a [`TxOut`] for the output + * requested or a [`UtxoLookupError`]. */ - LDKClosureReason_CounterpartyForceClosed, + LDKUtxoResult_Sync, /** - * Closure generated from [`ChannelManager::force_close_channel`], called by the user. + * A result which will be resolved asynchronously. It includes a [`UtxoFuture`], a `clone` of + * which you must keep locally and call [`UtxoFuture::resolve`] on once the lookup completes. * - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - */ - LDKClosureReason_HolderForceClosed, - /** - * The channel was closed after negotiating a cooperative close and we've now broadcasted - * the cooperative close transaction. Note the shutdown may have been initiated by us. - */ - LDKClosureReason_CooperativeClosure, - /** - * A commitment transaction was confirmed on chain, closing the channel. Most likely this - * commitment transaction came from our counterparty, but it may also have come from - * a copy of our own `ChannelMonitor`. + * Note that in order to avoid runaway memory usage, the number of parallel checks is limited, + * but only fairly loosely. Because a pending checks block all message processing, leaving + * checks pending for an extended time may cause DoS of other functions. It is recommended you + * keep a tight timeout on lookups, on the order of a few seconds. */ - LDKClosureReason_CommitmentTxConfirmed, + LDKUtxoResult_Async, /** - * The funding transaction failed to confirm in a timely manner on an inbound channel. + * Must be last for serialization purposes */ - LDKClosureReason_FundingTimedOut, + LDKUtxoResult_Sentinel, +} LDKUtxoResult_Tag; + +typedef struct MUST_USE_STRUCT LDKUtxoResult { + LDKUtxoResult_Tag tag; + union { + struct { + struct LDKCResult_TxOutUtxoLookupErrorZ sync; + }; + struct { + struct LDKUtxoFuture async; + }; + }; +} LDKUtxoResult; + +/** + * The `UtxoLookup` trait defines behavior for accessing on-chain UTXOs. + */ +typedef struct LDKUtxoLookup { /** - * Closure generated from processing an event, likely a HTLC forward/relay/reception. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKClosureReason_ProcessingError, + void *this_arg; /** - * The peer disconnected prior to funding completing. In this case the spec mandates that we - * forget the channel entirely - we can attempt again if the peer reconnects. - * - * This includes cases where we restarted prior to funding completion, including prior to the - * initial [`ChannelMonitor`] persistence completing. - * - * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the - * peer because of mutual incompatibility between us and our channel counterparty. + * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. + * Returns an error if `genesis_hash` is for a different chain or if such a transaction output + * is unknown. * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id */ - LDKClosureReason_DisconnectedPeer, + struct LDKUtxoResult (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); /** - * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than - * the [`ChannelManager`] deserialized. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - LDKClosureReason_OutdatedChannelManager, + void (*free)(void *this_arg); +} LDKUtxoLookup; + +/** + * An enum which can either contain a crate::lightning::routing::utxo::UtxoLookup or not + */ +typedef enum LDKCOption_UtxoLookupZ_Tag { /** - * Must be last for serialization purposes + * When we're in this state, this COption_UtxoLookupZ contains a crate::lightning::routing::utxo::UtxoLookup */ - LDKClosureReason_Sentinel, -} LDKClosureReason_Tag; - -typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { + LDKCOption_UtxoLookupZ_Some, /** - * The error which the peer sent us. - * - * Be careful about printing the peer_msg, a well-crafted message could exploit - * a security vulnerability in the terminal emulator or the logging subsystem. - * To be safe, use `Display` on `UntrustedString` - * - * [`UntrustedString`]: crate::util::string::UntrustedString + * When we're in this state, this COption_UtxoLookupZ contains nothing */ - struct LDKUntrustedString peer_msg; -} LDKClosureReason_LDKCounterpartyForceClosed_Body; - -typedef struct LDKClosureReason_LDKProcessingError_Body { + LDKCOption_UtxoLookupZ_None, /** - * A developer-readable error message which we generated. + * Must be last for serialization purposes */ - struct LDKStr err; -} LDKClosureReason_LDKProcessingError_Body; + LDKCOption_UtxoLookupZ_Sentinel, +} LDKCOption_UtxoLookupZ_Tag; -typedef struct MUST_USE_STRUCT LDKClosureReason { - LDKClosureReason_Tag tag; +typedef struct LDKCOption_UtxoLookupZ { + LDKCOption_UtxoLookupZ_Tag tag; union { - LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; - LDKClosureReason_LDKProcessingError_Body processing_error; + struct { + struct LDKUtxoLookup some; + }; }; -} LDKClosureReason; +} LDKCOption_UtxoLookupZ; /** - * An enum which can either contain a crate::lightning::events::ClosureReason or not + * The contents of CResult_NoneLightningErrorZ */ -typedef enum LDKCOption_ClosureReasonZ_Tag { +typedef union LDKCResult_NoneLightningErrorZPtr { /** - * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKCOption_ClosureReasonZ_Some, + void *result; /** - * When we're in this state, this COption_ClosureReasonZ contains nothing + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_ClosureReasonZ_None, + struct LDKLightningError *err; +} LDKCResult_NoneLightningErrorZPtr; + +/** + * A CResult_NoneLightningErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneLightningErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_NoneLightningErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_ClosureReasonZ_Sentinel, -} LDKCOption_ClosureReasonZ_Tag; - -typedef struct LDKCOption_ClosureReasonZ { - LDKCOption_ClosureReasonZ_Tag tag; - union { - struct { - struct LDKClosureReason some; - }; - }; -} LDKCOption_ClosureReasonZ; + union LDKCResult_NoneLightningErrorZPtr contents; + /** + * Whether this CResult_NoneLightningErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneLightningErrorZ; /** - * The contents of CResult_COption_ClosureReasonZDecodeErrorZ + * The contents of CResult_boolLightningErrorZ */ -typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr { +typedef union LDKCResult_boolLightningErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_ClosureReasonZ *result; + bool *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr; + struct LDKLightningError *err; +} LDKCResult_boolLightningErrorZPtr; /** - * A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_boolLightningErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { +typedef struct LDKCResult_boolLightningErrorZ { /** - * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either + * The contents of this CResult_boolLightningErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents; + union LDKCResult_boolLightningErrorZPtr contents; /** - * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + * Whether this CResult_boolLightningErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_ClosureReasonZDecodeErrorZ; +} LDKCResult_boolLightningErrorZ; + + /** - * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. + * A [`channel_announcement`] message to be sent to or received from a peer. + * + * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message */ -typedef enum LDKHTLCDestination_Tag { +typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { /** - * We tried forwarding to a channel but failed to do so. An example of such an instance is when - * there is insufficient capacity in our outbound channel. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKHTLCDestination_NextHopChannel, + LDKnativeChannelAnnouncement *inner; /** - * Scenario where we are unsure of the next node to forward the HTLC to. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKHTLCDestination_UnknownNextHop, + bool is_owned; +} LDKChannelAnnouncement; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { /** - * We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate - * intercept HTLC. + * The element at position 0 */ - LDKHTLCDestination_InvalidForward, + struct LDKChannelAnnouncement a; /** - * Failure scenario where an HTLC may have been forwarded to be intended for us, - * but is invalid for some reason, so we reject it. - * - * Some of the reasons may include: - * * HTLC Timeouts - * * Excess HTLCs for a payment that we have already fully received, over-paying for the - * payment, - * * The counterparty node modified the HTLC in transit, - * * A probing attack where an intermediary node is trying to detect if we are the ultimate - * recipient for a payment. + * The element at position 1 */ - LDKHTLCDestination_FailedPayment, + struct LDKChannelUpdate b; /** - * Must be last for serialization purposes + * The element at position 2 */ - LDKHTLCDestination_Sentinel, -} LDKHTLCDestination_Tag; + struct LDKChannelUpdate c; +} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; -typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { +/** + * An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not + */ +typedef enum LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag { /** - * The `node_id` of the next node. For backwards compatibility, this field is - * marked as optional, versions prior to 0.0.110 may not always be able to provide - * counterparty node information. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ */ - struct LDKPublicKey node_id; + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some, /** - * The outgoing `channel_id` between us and the next node. + * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing */ - struct LDKThirtyTwoBytes channel_id; -} LDKHTLCDestination_LDKNextHopChannel_Body; - -typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None, /** - * Short channel id we are requesting to forward an HTLC to. + * Must be last for serialization purposes */ - uint64_t requested_forward_scid; -} LDKHTLCDestination_LDKUnknownNextHop_Body; + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Sentinel, +} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag; -typedef struct LDKHTLCDestination_LDKInvalidForward_Body { +typedef struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag tag; + union { + struct { + struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ some; + }; + }; +} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; + + + +/** + * An [`accept_channel`] message to be sent to or received from a peer. + * + * Used in V1 channel establishment + * + * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message + */ +typedef struct MUST_USE_STRUCT LDKAcceptChannel { /** - * Short channel id we are requesting to forward an HTLC to. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - uint64_t requested_forward_scid; -} LDKHTLCDestination_LDKInvalidForward_Body; - -typedef struct LDKHTLCDestination_LDKFailedPayment_Body { + LDKnativeAcceptChannel *inner; /** - * The payment hash of the payment we attempted to process. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_hash; -} LDKHTLCDestination_LDKFailedPayment_Body; + bool is_owned; +} LDKAcceptChannel; + -typedef struct MUST_USE_STRUCT LDKHTLCDestination { - LDKHTLCDestination_Tag tag; - union { - LDKHTLCDestination_LDKNextHopChannel_Body next_hop_channel; - LDKHTLCDestination_LDKUnknownNextHop_Body unknown_next_hop; - LDKHTLCDestination_LDKInvalidForward_Body invalid_forward; - LDKHTLCDestination_LDKFailedPayment_Body failed_payment; - }; -} LDKHTLCDestination; /** - * An enum which can either contain a crate::lightning::events::HTLCDestination or not + * An accept_channel2 message to be sent by or received from the channel accepter. + * + * Used in V2 channel establishment + * */ -typedef enum LDKCOption_HTLCDestinationZ_Tag { - /** - * When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination - */ - LDKCOption_HTLCDestinationZ_Some, +typedef struct MUST_USE_STRUCT LDKAcceptChannelV2 { /** - * When we're in this state, this COption_HTLCDestinationZ contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_HTLCDestinationZ_None, + LDKnativeAcceptChannelV2 *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_HTLCDestinationZ_Sentinel, -} LDKCOption_HTLCDestinationZ_Tag; + bool is_owned; +} LDKAcceptChannelV2; + -typedef struct LDKCOption_HTLCDestinationZ { - LDKCOption_HTLCDestinationZ_Tag tag; - union { - struct { - struct LDKHTLCDestination some; - }; - }; -} LDKCOption_HTLCDestinationZ; /** - * The contents of CResult_COption_HTLCDestinationZDecodeErrorZ + * An [`open_channel`] message to be sent to or received from a peer. + * + * Used in V1 channel establishment + * + * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message */ -typedef union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKOpenChannel { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKCOption_HTLCDestinationZ *result; + LDKnativeOpenChannel *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr; + bool is_owned; +} LDKOpenChannel; + + /** - * A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An open_channel2 message to be sent by or received from the channel initiator. + * + * Used in V2 channel establishment + * */ -typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKOpenChannelV2 { /** - * The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr contents; + LDKnativeOpenChannelV2 *inner; /** - * Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_COption_HTLCDestinationZDecodeErrorZ; + bool is_owned; +} LDKOpenChannelV2; + + /** - * The contents of CResult_PaymentFailureReasonDecodeErrorZ + * A [`funding_created`] message to be sent to or received from a peer. + * + * Used in V1 channel establishment + * + * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message */ -typedef union LDKCResult_PaymentFailureReasonDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKFundingCreated { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - enum LDKPaymentFailureReason *result; + LDKnativeFundingCreated *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_PaymentFailureReasonDecodeErrorZPtr; + bool is_owned; +} LDKFundingCreated; + + /** - * A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A [`funding_signed`] message to be sent to or received from a peer. + * + * Used in V1 channel establishment + * + * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message */ -typedef struct LDKCResult_PaymentFailureReasonDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_PaymentFailureReasonDecodeErrorZPtr contents; + LDKnativeFundingSigned *inner; /** - * Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_PaymentFailureReasonDecodeErrorZ; + bool is_owned; +} LDKFundingSigned; + + /** - * An enum which can either contain a crate::c_types::U128 or not + * A tx_add_input message for adding an input during interactive transaction construction + * */ -typedef enum LDKCOption_u128Z_Tag { - /** - * When we're in this state, this COption_u128Z contains a crate::c_types::U128 - */ - LDKCOption_u128Z_Some, +typedef struct MUST_USE_STRUCT LDKTxAddInput { /** - * When we're in this state, this COption_u128Z contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_u128Z_None, + LDKnativeTxAddInput *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_u128Z_Sentinel, -} LDKCOption_u128Z_Tag; + bool is_owned; +} LDKTxAddInput; + -typedef struct LDKCOption_u128Z { - LDKCOption_u128Z_Tag tag; - union { - struct { - struct LDKU128 some; - }; - }; -} LDKCOption_u128Z; /** - * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not + * A tx_add_output message for adding an output during interactive transaction construction. + * */ -typedef enum LDKCOption_PaymentFailureReasonZ_Tag { +typedef struct MUST_USE_STRUCT LDKTxAddOutput { /** - * When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason - */ - LDKCOption_PaymentFailureReasonZ_Some, - /** - * When we're in this state, this COption_PaymentFailureReasonZ contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_PaymentFailureReasonZ_None, + LDKnativeTxAddOutput *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_PaymentFailureReasonZ_Sentinel, -} LDKCOption_PaymentFailureReasonZ_Tag; - -typedef struct LDKCOption_PaymentFailureReasonZ { - LDKCOption_PaymentFailureReasonZ_Tag tag; - union { - struct { - enum LDKPaymentFailureReason some; - }; - }; -} LDKCOption_PaymentFailureReasonZ; + bool is_owned; +} LDKTxAddOutput; /** - * Information about a spendable output to a P2WSH script. + * A tx_remove_input message for removing an input during interactive transaction construction. * - * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKTxRemoveInput { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDelayedPaymentOutputDescriptor *inner; + LDKnativeTxRemoveInput *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDelayedPaymentOutputDescriptor; +} LDKTxRemoveInput; /** - * Information about a spendable output to our \"payment key\". + * A tx_remove_output message for removing an output during interactive transaction construction. * - * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKTxRemoveOutput { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeStaticPaymentOutputDescriptor *inner; + LDKnativeTxRemoveOutput *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKStaticPaymentOutputDescriptor; +} LDKTxRemoveOutput; + + /** - * Describes the necessary information to spend a spendable output. - * - * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any - * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able - * to spend on-chain. The information needed to do this is provided in this enum, including the - * outpoint describing which `txid` and output `index` is available, the full output which exists - * at that `txid`/`index`, and any keys or other information required to sign. + * A tx_complete message signalling the conclusion of a peer's transaction contributions during + * interactive transaction construction. * - * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs */ -typedef enum LDKSpendableOutputDescriptor_Tag { +typedef struct MUST_USE_STRUCT LDKTxComplete { /** - * An output to a script which was provided via [`SignerProvider`] directly, either from - * [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already - * know how to spend it. No secret keys are provided as LDK was never given any key. - * These may include outputs from a transaction punishing our counterparty or claiming an HTLC - * on-chain using the payment preimage or after it has timed out. - * - * [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey - * [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKSpendableOutputDescriptor_StaticOutput, + LDKnativeTxComplete *inner; /** - * An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` - * delay. - * - * The witness in the spending input should be: - * ```bitcoin - * (MINIMALIF standard rule) - * ``` - * - * Note that the `nSequence` field in the spending input must be set to - * [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not - * broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after - * the outpoint confirms, see [BIP - * 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK - * won't generate a [`SpendableOutputDescriptor`] until the corresponding block height - * is reached. - * - * These are generally the result of a \"revocable\" output to us, spendable only by us unless - * it is an output from an old state which we broadcast (which should never happen). - * - * To derive the delayed payment key which is used to sign this input, you must pass the - * holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the - * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided - * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be - * generated without the secret key using [`chan_utils::derive_public_key`] and only the - * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. - * - * To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is - * used in the witness script generation), you must pass the counterparty - * [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to - * [`ChannelSigner::provide_channel_parameters`]) and the provided - * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to - * [`chan_utils::derive_public_revocation_key`]. - * - * The witness script which is hashed and included in the output `script_pubkey` may be - * regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived - * as explained above), our delayed payment pubkey (derived as explained above), and the - * [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to - * [`chan_utils::get_revokeable_redeemscript`]. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKSpendableOutputDescriptor_DelayedPaymentOutput, + bool is_owned; +} LDKTxComplete; + + + +/** + * A tx_signatures message containing the sender's signatures for a transaction constructed with + * interactive transaction construction. + * + */ +typedef struct MUST_USE_STRUCT LDKTxSignatures { /** - * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key - * which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness - * in the spending input is, thus, simply: - * ```bitcoin - * - * ``` - * - * These are generally the result of our counterparty having broadcast the current state, - * allowing us to claim the non-HTLC-encumbered outputs immediately. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKSpendableOutputDescriptor_StaticPaymentOutput, + LDKnativeTxSignatures *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKSpendableOutputDescriptor_Sentinel, -} LDKSpendableOutputDescriptor_Tag; + bool is_owned; +} LDKTxSignatures; -typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { + + +/** + * A tx_init_rbf message which initiates a replacement of the transaction after it's been + * completed. + * + */ +typedef struct MUST_USE_STRUCT LDKTxInitRbf { /** - * The outpoint which is spendable. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKOutPoint outpoint; + LDKnativeTxInitRbf *inner; /** - * The output which is referenced by the given outpoint. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKTxOut output; -} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; + bool is_owned; +} LDKTxInitRbf; + -typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { - LDKSpendableOutputDescriptor_Tag tag; - union { - LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; - struct { - struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; - }; - struct { - struct LDKStaticPaymentOutputDescriptor static_payment_output; - }; - }; -} LDKSpendableOutputDescriptor; /** - * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. - * This corresponds to std::vector in C++ + * A tx_ack_rbf message which acknowledges replacement of the transaction after it's been + * completed. + * */ -typedef struct LDKCVec_SpendableOutputDescriptorZ { +typedef struct MUST_USE_STRUCT LDKTxAckRbf { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKSpendableOutputDescriptor *data; + LDKnativeTxAckRbf *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_SpendableOutputDescriptorZ; + bool is_owned; +} LDKTxAckRbf; + + /** - * An Event which you should probably take some action in response to. + * A [`channel_ready`] message to be sent to or received from a peer. * - * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use - * them directly as they don't round-trip exactly (for example FundingGenerationReady is never - * written as it makes no sense to respond to it after reconnecting to peers). + * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message */ -typedef enum LDKEvent_Tag { +typedef struct MUST_USE_STRUCT LDKChannelReady { /** - * Used to indicate that the client should generate a funding transaction with the given - * parameters and then call [`ChannelManager::funding_transaction_generated`]. - * Generated in [`ChannelManager`] message handling. - * Note that *all inputs* in the funding transaction must spend SegWit outputs or your - * counterparty can steal your funds! - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_FundingGenerationReady, + LDKnativeChannelReady *inner; /** - * Indicates that we've been offered a payment and it needs to be claimed via calling - * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. - * - * Note that if the preimage is not known, you should call - * [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] - * to free up resources for this HTLC and avoid network congestion. - * If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], - * or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be - * automatically failed. - * - * # Note - * LDK will not stop an inbound payment from being paid multiple times, so multiple - * `PaymentClaimable` events may be generated for the same payment. In such a case it is - * polite (and required in the lightning specification) to fail the payment the second time - * and give the sender their money back rather than accepting double payment. - * - * # Note - * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards - * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PaymentClaimable, + bool is_owned; +} LDKChannelReady; + + + +/** + * An [`announcement_signatures`] message to be sent to or received from a peer. + * + * [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message + */ +typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { /** - * Indicates a payment has been claimed and we've received money! - * - * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response - * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a - * [`ChannelManager::claim_funds`] call you may see this event without a corresponding - * [`Event::PaymentClaimable`] event. - * - * # Note - * LDK will not stop an inbound payment from being paid multiple times, so multiple - * `PaymentClaimable` events may be generated for the same payment. If you then call - * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get - * multiple `PaymentClaimed` events. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_PaymentClaimed, + LDKnativeAnnouncementSignatures *inner; /** - * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target - * and we got back the payment preimage for it). - * - * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` - * event. In this situation, you SHOULD treat this payment as having succeeded. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PaymentSent, + bool is_owned; +} LDKAnnouncementSignatures; + + + +/** + * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment + * transaction updates if they were pending. + */ +typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { /** - * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events - * provide failure information for each path attempt in the payment, including retries. - * - * This event is provided once there are no further pending HTLCs for the payment and the - * payment is no longer retryable, due either to the [`Retry`] provided or - * [`ChannelManager::abandon_payment`] having been called for the corresponding payment. - * - * [`Retry`]: crate::ln::channelmanager::Retry - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_PaymentFailed, + LDKnativeCommitmentUpdate *inner; /** - * Indicates that a path for an outbound payment was successful. - * - * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See - * [`Event::PaymentSent`] for obtaining the payment preimage. - */ - LDKEvent_PaymentPathSuccessful, - /** - * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to - * handle the HTLC. - * - * Note that this does *not* indicate that all paths for an MPP payment have failed, see - * [`Event::PaymentFailed`]. - * - * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have - * been exhausted. - * - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - */ - LDKEvent_PaymentPathFailed, - /** - * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_ProbeSuccessful, + bool is_owned; +} LDKCommitmentUpdate; + + + +/** + * A [`revoke_and_ack`] message to be sent to or received from a peer. + * + * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack + */ +typedef struct MUST_USE_STRUCT LDKRevokeAndACK { /** - * Indicates that a probe payment we sent failed at an intermediary node on the path. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_ProbeFailed, + LDKnativeRevokeAndACK *inner; /** - * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at - * a time in the future. - * - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PendingHTLCsForwardable, + bool is_owned; +} LDKRevokeAndACK; + + + +/** + * A [`closing_signed`] message to be sent to or received from a peer. + * + * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed + */ +typedef struct MUST_USE_STRUCT LDKClosingSigned { /** - * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if - * you've encoded an intercept scid in the receiver's invoice route hints using - * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. - * - * [`ChannelManager::forward_intercepted_htlc`] or - * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See - * their docs for more information. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc - * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_HTLCIntercepted, + LDKnativeClosingSigned *inner; /** - * Used to indicate that an output which you should know how to spend was confirmed on chain - * and is now spendable. - * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - * counterparty spending them due to some kind of timeout. Thus, you need to store them - * somewhere and spend them when you create on-chain transactions. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_SpendableOutputs, + bool is_owned; +} LDKClosingSigned; + + + +/** + * A [`shutdown`] message to be sent to or received from a peer. + * + * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown + */ +typedef struct MUST_USE_STRUCT LDKShutdown { /** - * This event is generated when a payment has been successfully forwarded through us and a - * forwarding fee earned. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_PaymentForwarded, + LDKnativeShutdown *inner; /** - * Used to indicate that a channel with the given `channel_id` is being opened and pending - * confirmation on-chain. - * - * This event is emitted when the funding transaction has been signed and is broadcast to the - * network. For 0conf channels it will be immediately followed by the corresponding - * [`Event::ChannelReady`] event. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_ChannelPending, + bool is_owned; +} LDKShutdown; + + + +/** + * A [`channel_reestablish`] message to be sent to or received from a peer. + * + * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission + */ +typedef struct MUST_USE_STRUCT LDKChannelReestablish { /** - * Used to indicate that a channel with the given `channel_id` is ready to - * be used. This event is emitted either when the funding transaction has been confirmed - * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel - * establishment. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_ChannelReady, + LDKnativeChannelReestablish *inner; /** - * Used to indicate that a previously opened channel with the given `channel_id` is in the - * process of closure. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_ChannelClosed, + bool is_owned; +} LDKChannelReestablish; + + + +/** + * A [`node_announcement`] message to be sent to or received from a peer. + * + * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message + */ +typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** - * Used to indicate to the user that they can abandon the funding transaction and recycle the - * inputs for another purpose. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_DiscardFunding, + LDKnativeNodeAnnouncement *inner; /** - * Indicates a request to open a new channel by a peer. - * - * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the - * request, call [`ChannelManager::force_close_without_broadcasting_txn`]. - * - * The event is only triggered when a new open channel request is received and the - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. - * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_OpenChannelRequest, + bool is_owned; +} LDKNodeAnnouncement; + + + +/** + * An [`error`] message to be sent to or received from a peer. + * + * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + */ +typedef struct MUST_USE_STRUCT LDKErrorMessage { /** - * Indicates that the HTLC was accepted, but could not be processed when or after attempting to - * forward it. - * - * Some scenarios where this event may be sent include: - * * Insufficient capacity in the outbound channel - * * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes - * * When an unknown SCID is requested for forwarding a payment. - * * Expected MPP amount has already been reached - * * The HTLC has timed out - * - * This event, however, does not get generated if an HTLC fails to meet the forwarding - * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_HTLCHandlingFailed, + LDKnativeErrorMessage *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_Sentinel, -} LDKEvent_Tag; + bool is_owned; +} LDKErrorMessage; -typedef struct LDKEvent_LDKFundingGenerationReady_Body { + + +/** + * A [`warning`] message to be sent to or received from a peer. + * + * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + */ +typedef struct MUST_USE_STRUCT LDKWarningMessage { /** - * The random channel_id we picked which you'll need to pass into - * [`ChannelManager::funding_transaction_generated`]. - * - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes temporary_channel_id; + LDKnativeWarningMessage *inner; /** - * The counterparty's node_id, which you'll need to pass back into - * [`ChannelManager::funding_transaction_generated`]. - * - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKPublicKey counterparty_node_id; + bool is_owned; +} LDKWarningMessage; + +/** + * Used to put an error message in a [`LightningError`]. + */ +typedef enum LDKErrorAction_Tag { /** - * The value, in satoshis, that the output should have. + * The peer took some action which made us think they were useless. Disconnect them. */ - uint64_t channel_value_satoshis; + LDKErrorAction_DisconnectPeer, /** - * The script which should be used in the transaction output. + * The peer did something incorrect. Tell them without closing any channels and disconnect them. */ - struct LDKCVec_u8Z output_script; + LDKErrorAction_DisconnectPeerWithWarning, /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a - * random value for an inbound channel. This may be zero for objects serialized with LDK - * versions prior to 0.0.113. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * The peer did something harmless that we weren't able to process, just log and ignore */ - struct LDKU128 user_channel_id; -} LDKEvent_LDKFundingGenerationReady_Body; - -typedef struct LDKEvent_LDKPaymentClaimable_Body { + LDKErrorAction_IgnoreError, /** - * The node that will receive the payment after it has been claimed. - * This is useful to identify payments received via [phantom nodes]. - * This field will always be filled in when the event was generated by LDK versions - * 0.0.113 and above. - * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The peer did something harmless that we weren't able to meaningfully process. + * If the error is logged, log it at the given level. */ - struct LDKPublicKey receiver_node_id; + LDKErrorAction_IgnoreAndLog, /** - * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will - * not stop you from registering duplicate payment hashes for inbound payments. + * The peer provided us with a gossip message which we'd already seen. In most cases this + * should be ignored, but it may result in the message being forwarded if it is a duplicate of + * our own channel announcements. */ - struct LDKThirtyTwoBytes payment_hash; + LDKErrorAction_IgnoreDuplicateGossip, /** - * The fields in the onion which were received with each HTLC. Only fields which were - * identical in each HTLC involved in the payment will be included here. - * - * Payments received on LDK versions prior to 0.0.115 will have this field unset. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The peer did something incorrect. Tell them. */ - struct LDKRecipientOnionFields onion_fields; + LDKErrorAction_SendErrorMessage, /** - * The value, in thousandths of a satoshi, that this payment is for. + * The peer did something incorrect. Tell them without closing any channels. */ - uint64_t amount_msat; + LDKErrorAction_SendWarningMessage, /** - * Information for claiming this received payment, based on whether the purpose of the - * payment is to pay an invoice or to send a spontaneous payment. + * Must be last for serialization purposes */ - struct LDKPaymentPurpose purpose; + LDKErrorAction_Sentinel, +} LDKErrorAction_Tag; + +typedef struct LDKErrorAction_LDKDisconnectPeer_Body { /** - * The `channel_id` indicating over which channel we received the payment. + * An error message which we should make an effort to send before we disconnect. * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKThirtyTwoBytes via_channel_id; + struct LDKErrorMessage msg; +} LDKErrorAction_LDKDisconnectPeer_Body; + +typedef struct LDKErrorAction_LDKDisconnectPeerWithWarning_Body { /** - * The `user_channel_id` indicating over which channel we received the payment. + * A warning message which we should make an effort to send before we disconnect. */ - struct LDKCOption_u128Z via_user_channel_id; + struct LDKWarningMessage msg; +} LDKErrorAction_LDKDisconnectPeerWithWarning_Body; + +typedef struct LDKErrorAction_LDKSendErrorMessage_Body { /** - * The block height at which this payment will be failed back and will no longer be - * eligible for claiming. - * - * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to - * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * The message to send. */ - struct LDKCOption_u32Z claim_deadline; -} LDKEvent_LDKPaymentClaimable_Body; + struct LDKErrorMessage msg; +} LDKErrorAction_LDKSendErrorMessage_Body; -typedef struct LDKEvent_LDKPaymentClaimed_Body { +typedef struct LDKErrorAction_LDKSendWarningMessage_Body { /** - * The node that received the payment. - * This is useful to identify payments which were received via [phantom nodes]. - * This field will always be filled in when the event was generated by LDK versions - * 0.0.113 and above. - * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The message to send. */ - struct LDKPublicKey receiver_node_id; + struct LDKWarningMessage msg; /** - * The payment hash of the claimed payment. Note that LDK will not stop you from - * registering duplicate payment hashes for inbound payments. + * The peer may have done something harmless that we weren't able to meaningfully process, + * though we should still tell them about it. + * If this event is logged, log it at the given level. */ - struct LDKThirtyTwoBytes payment_hash; + enum LDKLevel log_level; +} LDKErrorAction_LDKSendWarningMessage_Body; + +typedef struct MUST_USE_STRUCT LDKErrorAction { + LDKErrorAction_Tag tag; + union { + LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer; + LDKErrorAction_LDKDisconnectPeerWithWarning_Body disconnect_peer_with_warning; + struct { + enum LDKLevel ignore_and_log; + }; + LDKErrorAction_LDKSendErrorMessage_Body send_error_message; + LDKErrorAction_LDKSendWarningMessage_Body send_warning_message; + }; +} LDKErrorAction; + + + +/** + * A [`query_channel_range`] message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more [`ReplyChannelRange`] + * messages. + * + * [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages + */ +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { /** - * The value, in thousandths of a satoshi, that this payment is for. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - uint64_t amount_msat; + LDKnativeQueryChannelRange *inner; /** - * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a - * spontaneous payment. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKPaymentPurpose purpose; -} LDKEvent_LDKPaymentClaimed_Body; + bool is_owned; +} LDKQueryChannelRange; -typedef struct LDKEvent_LDKPaymentSent_Body { + + +/** + * A [`query_short_channel_ids`] message is used to query a peer for + * routing gossip messages related to one or more `short_channel_id`s. + * + * The query recipient will reply with the latest, if available, + * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages + * it maintains for the requested `short_channel_id`s followed by a + * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in + * this query are encoded. We only support `encoding_type=0` uncompressed + * serialization and do not support `encoding_type=1` zlib serialization. + * + * [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages + */ +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { /** - * The `payment_id` passed to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes payment_id; + LDKnativeQueryShortChannelIds *inner; /** - * 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 - * store it somehow! + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_preimage; + bool is_owned; +} LDKQueryShortChannelIds; + + + +/** + * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`] + * message. + * + * Multiple `reply_channel_range` messages can be sent in reply + * to a single [`QueryChannelRange`] message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The `short_channel_id`s in the + * reply are encoded. We only support `encoding_type=0` uncompressed + * serialization and do not support `encoding_type=1` zlib serialization. + * + * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages + */ +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes payment_hash; + LDKnativeReplyChannelRange *inner; /** - * 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 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCOption_u64Z fee_paid_msat; -} LDKEvent_LDKPaymentSent_Body; + bool is_owned; +} LDKReplyChannelRange; -typedef struct LDKEvent_LDKPaymentFailed_Body { + + +/** + * A [`gossip_timestamp_filter`] message is used by a node to request + * gossip relay for messages in the requested time range when the + * `gossip_queries` feature has been negotiated. + * + * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message + */ +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { /** - * The `payment_id` passed to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes payment_id; + LDKnativeGossipTimestampFilter *inner; /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_hash; + bool is_owned; +} LDKGossipTimestampFilter; + +/** + * An event generated by ChannelManager which indicates a message should be sent to a peer (or + * broadcast to most peers). + * These events are handled by PeerManager::process_events if you are using a PeerManager. + */ +typedef enum LDKMessageSendEvent_Tag { /** - * The reason the payment failed. This is only `None` for events generated or serialized - * by versions prior to 0.0.115. + * Used to indicate that we've accepted a channel open and should send the accept_channel + * message provided to the given peer. */ - struct LDKCOption_PaymentFailureReasonZ reason; -} LDKEvent_LDKPaymentFailed_Body; - -typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { + LDKMessageSendEvent_SendAcceptChannel, /** - * The `payment_id` passed to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * Used to indicate that we've accepted a V2 channel open and should send the accept_channel2 + * message provided to the given peer. */ - struct LDKThirtyTwoBytes payment_id; + LDKMessageSendEvent_SendAcceptChannelV2, /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Used to indicate that we've initiated a channel open and should send the open_channel + * message provided to the given peer. */ - struct LDKThirtyTwoBytes payment_hash; + LDKMessageSendEvent_SendOpenChannel, /** - * The payment path that was successful. - * - * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. + * Used to indicate that we've initiated a V2 channel open and should send the open_channel2 + * message provided to the given peer. */ - struct LDKPath path; -} LDKEvent_LDKPaymentPathSuccessful_Body; - -typedef struct LDKEvent_LDKPaymentPathFailed_Body { + LDKMessageSendEvent_SendOpenChannelV2, /** - * The `payment_id` passed to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Used to indicate that a funding_created message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_id; + LDKMessageSendEvent_SendFundingCreated, /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_hash; + LDKMessageSendEvent_SendFundingSigned, /** - * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, the payment may - * be retried via a different route. + * Used to indicate that a tx_add_input message should be sent to the peer with the given node_id. */ - bool payment_failed_permanently; + LDKMessageSendEvent_SendTxAddInput, /** - * Extra error details based on the failure type. May contain an update that needs to be - * applied to the [`NetworkGraph`]. - * - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * Used to indicate that a tx_add_output message should be sent to the peer with the given node_id. */ - struct LDKPathFailure failure; + LDKMessageSendEvent_SendTxAddOutput, /** - * The payment path that failed. + * Used to indicate that a tx_remove_input message should be sent to the peer with the given node_id. */ - struct LDKPath path; + LDKMessageSendEvent_SendTxRemoveInput, /** - * The channel responsible for the failed payment path. - * - * Note that for route hints or for the first hop in a path this may be an SCID alias and - * may not refer to a channel in the public network graph. These aliases may also collide - * with channels in the public network graph. - * - * If this is `Some`, then the corresponding channel should be avoided when the payment is - * retried. May be `None` for older [`Event`] serializations. + * Used to indicate that a tx_remove_output message should be sent to the peer with the given node_id. */ - struct LDKCOption_u64Z short_channel_id; -} LDKEvent_LDKPaymentPathFailed_Body; - -typedef struct LDKEvent_LDKProbeSuccessful_Body { + LDKMessageSendEvent_SendTxRemoveOutput, /** - * The id returned by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Used to indicate that a tx_complete message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_id; + LDKMessageSendEvent_SendTxComplete, /** - * The hash generated by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Used to indicate that a tx_signatures message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_hash; + LDKMessageSendEvent_SendTxSignatures, /** - * The payment path that was successful. + * Used to indicate that a tx_init_rbf message should be sent to the peer with the given node_id. */ - struct LDKPath path; -} LDKEvent_LDKProbeSuccessful_Body; - -typedef struct LDKEvent_LDKProbeFailed_Body { + LDKMessageSendEvent_SendTxInitRbf, /** - * The id returned by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Used to indicate that a tx_ack_rbf message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_id; + LDKMessageSendEvent_SendTxAckRbf, /** - * The hash generated by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Used to indicate that a tx_abort message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_hash; + LDKMessageSendEvent_SendTxAbort, /** - * The payment path that failed. + * Used to indicate that a channel_ready message should be sent to the peer with the given node_id. */ - struct LDKPath path; + LDKMessageSendEvent_SendChannelReady, /** - * The channel responsible for the failed probe. - * - * Note that for route hints or for the first hop in a path this may be an SCID alias and - * may not refer to a channel in the public network graph. These aliases may also collide - * with channels in the public network graph. + * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. */ - struct LDKCOption_u64Z short_channel_id; -} LDKEvent_LDKProbeFailed_Body; - -typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { + LDKMessageSendEvent_SendAnnouncementSignatures, /** - * The minimum amount of time that should be waited prior to calling - * process_pending_htlc_forwards. To increase the effort required to correlate payments, - * you should wait a random amount of time in roughly the range (now + time_forwardable, - * now + 5*time_forwardable). + * Used to indicate that a series of HTLC update messages, as well as a commitment_signed + * message should be sent to the peer with the given node_id. */ - uint64_t time_forwardable; -} LDKEvent_LDKPendingHTLCsForwardable_Body; - -typedef struct LDKEvent_LDKHTLCIntercepted_Body { + LDKMessageSendEvent_UpdateHTLCs, /** - * An id to help LDK identify which HTLC is being forwarded or failed. + * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes intercept_id; + LDKMessageSendEvent_SendRevokeAndACK, /** - * The fake scid that was programmed as the next hop's scid, generated using - * [`ChannelManager::get_intercept_scid`]. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. */ - uint64_t requested_next_hop_scid; + LDKMessageSendEvent_SendClosingSigned, /** - * The payment hash used for this HTLC. + * Used to indicate that a shutdown message should be sent to the peer with the given node_id. */ - struct LDKThirtyTwoBytes payment_hash; + LDKMessageSendEvent_SendShutdown, /** - * How many msats were received on the inbound edge of this HTLC. + * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. */ - uint64_t inbound_amount_msat; + LDKMessageSendEvent_SendChannelReestablish, /** - * How many msats the payer intended to route to the next node. Depending on the reason you are - * intercepting this payment, you might take a fee by forwarding less than this amount. + * Used to send a channel_announcement and channel_update to a specific peer, likely on + * initial connection to ensure our peers know about our channels. + */ + LDKMessageSendEvent_SendChannelAnnouncement, + /** + * Used to indicate that a channel_announcement and channel_update should be broadcast to all + * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). * - * Note that LDK will NOT check that expected fees were factored into this value. You MUST - * check that whatever fee you want has been included here or subtract it as required. Further, - * LDK will not stop you from forwarding more than you received. + * Note that after doing so, you very likely (unless you did so very recently) want to + * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This + * ensures that any nodes which see our channel_announcement also have a relevant + * node_announcement, including relevant feature flags which may be important for routing + * through or to us. + * + * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement */ - uint64_t expected_outbound_amount_msat; -} LDKEvent_LDKHTLCIntercepted_Body; - -typedef struct LDKEvent_LDKSpendableOutputs_Body { + LDKMessageSendEvent_BroadcastChannelAnnouncement, /** - * The outputs which you should store as spendable by you. + * Used to indicate that a channel_update should be broadcast to all peers. */ - struct LDKCVec_SpendableOutputDescriptorZ outputs; -} LDKEvent_LDKSpendableOutputs_Body; - -typedef struct LDKEvent_LDKPaymentForwarded_Body { + LDKMessageSendEvent_BroadcastChannelUpdate, /** - * The incoming channel between the previous node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Used to indicate that a node_announcement should be broadcast to all peers. */ - struct LDKThirtyTwoBytes prev_channel_id; + LDKMessageSendEvent_BroadcastNodeAnnouncement, /** - * The outgoing channel between the next node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Used to indicate that a channel_update should be sent to a single peer. + * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a + * private channel and we shouldn't be informing all of our peers of channel parameters. */ - struct LDKThirtyTwoBytes next_channel_id; + LDKMessageSendEvent_SendChannelUpdate, /** - * The fee, in milli-satoshis, which was earned as a result of the payment. - * - * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC - * was pending, the amount the next hop claimed will have been rounded down to the nearest - * whole satoshi. Thus, the fee calculated here may be higher than expected as we still - * claimed the full value in millisatoshis from the source. In this case, - * `claim_from_onchain_tx` will be set. - * - * If the channel which sent us the payment has been force-closed, we will claim the funds - * via an on-chain transaction. In that case we do not yet know the on-chain transaction - * fees which we will spend and will instead set this to `None`. It is possible duplicate - * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is - * `None`. + * Broadcast an error downstream to be handled */ - struct LDKCOption_u64Z fee_earned_msat; + LDKMessageSendEvent_HandleError, /** - * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain - * transaction. + * Query a peer for channels with funding transaction UTXOs in a block range. */ - bool claim_from_onchain_tx; + LDKMessageSendEvent_SendChannelRangeQuery, /** - * The final amount forwarded, in milli-satoshis, after the fee is deducted. - * - * The caveat described above the `fee_earned_msat` field applies here as well. + * Request routing gossip messages from a peer for a list of channels identified by + * their short_channel_ids. */ - struct LDKCOption_u64Z outbound_amount_forwarded_msat; -} LDKEvent_LDKPaymentForwarded_Body; - -typedef struct LDKEvent_LDKChannelPending_Body { + LDKMessageSendEvent_SendShortIdsQuery, /** - * The `channel_id` of the channel that is pending confirmation. + * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + * emitted during processing of the query. */ - struct LDKThirtyTwoBytes channel_id; + LDKMessageSendEvent_SendReplyChannelRange, /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to + * enable receiving gossip messages from the peer. */ - struct LDKU128 user_channel_id; + LDKMessageSendEvent_SendGossipTimestampFilter, /** - * The `temporary_channel_id` this channel used to be known by during channel establishment. - * - * Will be `None` for channels created prior to LDK version 0.0.115. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Must be last for serialization purposes */ - struct LDKThirtyTwoBytes former_temporary_channel_id; + LDKMessageSendEvent_Sentinel, +} LDKMessageSendEvent_Tag; + +typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { /** - * The `node_id` of the channel counterparty. + * The node_id of the node which should receive this message */ - struct LDKPublicKey counterparty_node_id; + struct LDKPublicKey node_id; /** - * The outpoint of the channel's funding transaction. + * The message which should be sent. */ - struct LDKOutPoint funding_txo; -} LDKEvent_LDKChannelPending_Body; + struct LDKAcceptChannel msg; +} LDKMessageSendEvent_LDKSendAcceptChannel_Body; -typedef struct LDKEvent_LDKChannelReady_Body { +typedef struct LDKMessageSendEvent_LDKSendAcceptChannelV2_Body { /** - * The `channel_id` of the channel that is ready. + * The node_id of the node which should receive this message */ - struct LDKThirtyTwoBytes channel_id; + struct LDKPublicKey node_id; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * The message which should be sent. */ - struct LDKU128 user_channel_id; + struct LDKAcceptChannelV2 msg; +} LDKMessageSendEvent_LDKSendAcceptChannelV2_Body; + +typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { /** - * The `node_id` of the channel counterparty. + * The node_id of the node which should receive this message */ - struct LDKPublicKey counterparty_node_id; + struct LDKPublicKey node_id; /** - * The features that this channel will operate with. + * The message which should be sent. */ - struct LDKChannelTypeFeatures channel_type; -} LDKEvent_LDKChannelReady_Body; + struct LDKOpenChannel msg; +} LDKMessageSendEvent_LDKSendOpenChannel_Body; -typedef struct LDKEvent_LDKChannelClosed_Body { +typedef struct LDKMessageSendEvent_LDKSendOpenChannelV2_Body { /** - * The `channel_id` of the channel which has been closed. Note that on-chain transactions - * resolving the channel are likely still awaiting confirmation. + * The node_id of the node which should receive this message */ - struct LDKThirtyTwoBytes channel_id; + struct LDKPublicKey node_id; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for inbound channels. - * This may be zero for inbound channels serialized prior to 0.0.113 and will always be - * zero for objects serialized with LDK versions prior to 0.0.102. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * The message which should be sent. */ - struct LDKU128 user_channel_id; + struct LDKOpenChannelV2 msg; +} LDKMessageSendEvent_LDKSendOpenChannelV2_Body; + +typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { /** - * The reason the channel was closed. + * The node_id of the node which should receive this message */ - struct LDKClosureReason reason; -} LDKEvent_LDKChannelClosed_Body; + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKFundingCreated msg; +} LDKMessageSendEvent_LDKSendFundingCreated_Body; -typedef struct LDKEvent_LDKDiscardFunding_Body { +typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { /** - * The channel_id of the channel which has been closed. + * The node_id of the node which should receive this message */ - struct LDKThirtyTwoBytes channel_id; + struct LDKPublicKey node_id; /** - * The full transaction received from the user + * The message which should be sent. */ - struct LDKTransaction transaction; -} LDKEvent_LDKDiscardFunding_Body; + struct LDKFundingSigned msg; +} LDKMessageSendEvent_LDKSendFundingSigned_Body; -typedef struct LDKEvent_LDKOpenChannelRequest_Body { +typedef struct LDKMessageSendEvent_LDKSendTxAddInput_Body { /** - * The temporary channel ID of the channel requested to be opened. - * - * When responding to the request, the `temporary_channel_id` should be passed - * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, - * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. - * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + * The node_id of the node which should receive this message */ - struct LDKThirtyTwoBytes temporary_channel_id; + struct LDKPublicKey node_id; /** - * The node_id of the counterparty requesting to open the channel. - * - * When responding to the request, the `counterparty_node_id` should be passed - * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to - * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the - * request. - * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + * The message which should be sent. */ - struct LDKPublicKey counterparty_node_id; + struct LDKTxAddInput msg; +} LDKMessageSendEvent_LDKSendTxAddInput_Body; + +typedef struct LDKMessageSendEvent_LDKSendTxAddOutput_Body { /** - * The channel value of the requested channel. + * The node_id of the node which should receive this message */ - uint64_t funding_satoshis; + struct LDKPublicKey node_id; /** - * Our starting balance in the channel if the request is accepted, in milli-satoshi. + * The message which should be sent. */ - uint64_t push_msat; + struct LDKTxAddOutput msg; +} LDKMessageSendEvent_LDKSendTxAddOutput_Body; + +typedef struct LDKMessageSendEvent_LDKSendTxRemoveInput_Body { /** - * The features that this channel will operate with. If you reject the channel, a - * well-behaved counterparty may automatically re-attempt the channel with a new set of - * feature flags. - * - * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, - * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - * 0.0.106. - * - * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, - * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - * 0.0.107. Channels setting this type also need to get manually accepted via - * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], - * or will be rejected otherwise. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * The node_id of the node which should receive this message */ - struct LDKChannelTypeFeatures channel_type; -} LDKEvent_LDKOpenChannelRequest_Body; + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKTxRemoveInput msg; +} LDKMessageSendEvent_LDKSendTxRemoveInput_Body; -typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { +typedef struct LDKMessageSendEvent_LDKSendTxRemoveOutput_Body { /** - * The channel over which the HTLC was received. + * The node_id of the node which should receive this message */ - struct LDKThirtyTwoBytes prev_channel_id; + struct LDKPublicKey node_id; /** - * Destination of the HTLC that failed to be processed. + * The message which should be sent. */ - struct LDKHTLCDestination failed_next_destination; -} LDKEvent_LDKHTLCHandlingFailed_Body; - -typedef struct MUST_USE_STRUCT LDKEvent { - LDKEvent_Tag tag; - union { - LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; - LDKEvent_LDKPaymentClaimable_Body payment_claimable; - LDKEvent_LDKPaymentClaimed_Body payment_claimed; - LDKEvent_LDKPaymentSent_Body payment_sent; - LDKEvent_LDKPaymentFailed_Body payment_failed; - LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; - LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; - LDKEvent_LDKProbeSuccessful_Body probe_successful; - LDKEvent_LDKProbeFailed_Body probe_failed; - LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; - LDKEvent_LDKHTLCIntercepted_Body htlc_intercepted; - LDKEvent_LDKSpendableOutputs_Body spendable_outputs; - LDKEvent_LDKPaymentForwarded_Body payment_forwarded; - LDKEvent_LDKChannelPending_Body channel_pending; - LDKEvent_LDKChannelReady_Body channel_ready; - LDKEvent_LDKChannelClosed_Body channel_closed; - LDKEvent_LDKDiscardFunding_Body discard_funding; - LDKEvent_LDKOpenChannelRequest_Body open_channel_request; - LDKEvent_LDKHTLCHandlingFailed_Body htlc_handling_failed; - }; -} LDKEvent; + struct LDKTxRemoveOutput msg; +} LDKMessageSendEvent_LDKSendTxRemoveOutput_Body; -/** - * An enum which can either contain a crate::lightning::events::Event or not - */ -typedef enum LDKCOption_EventZ_Tag { +typedef struct LDKMessageSendEvent_LDKSendTxComplete_Body { /** - * When we're in this state, this COption_EventZ contains a crate::lightning::events::Event + * The node_id of the node which should receive this message */ - LDKCOption_EventZ_Some, + struct LDKPublicKey node_id; /** - * When we're in this state, this COption_EventZ contains nothing + * The message which should be sent. */ - LDKCOption_EventZ_None, + struct LDKTxComplete msg; +} LDKMessageSendEvent_LDKSendTxComplete_Body; + +typedef struct LDKMessageSendEvent_LDKSendTxSignatures_Body { /** - * Must be last for serialization purposes + * The node_id of the node which should receive this message */ - LDKCOption_EventZ_Sentinel, -} LDKCOption_EventZ_Tag; - -typedef struct LDKCOption_EventZ { - LDKCOption_EventZ_Tag tag; - union { - struct { - struct LDKEvent some; - }; - }; -} LDKCOption_EventZ; + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKTxSignatures msg; +} LDKMessageSendEvent_LDKSendTxSignatures_Body; -/** - * The contents of CResult_COption_EventZDecodeErrorZ - */ -typedef union LDKCResult_COption_EventZDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendTxInitRbf_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKCOption_EventZ *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The message which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_COption_EventZDecodeErrorZPtr; + struct LDKTxInitRbf msg; +} LDKMessageSendEvent_LDKSendTxInitRbf_Body; -/** - * A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_COption_EventZDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendTxAckRbf_Body { /** - * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive this message */ - union LDKCResult_COption_EventZDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + * The message which should be sent. */ - bool result_ok; -} LDKCResult_COption_EventZDecodeErrorZ; - + struct LDKTxAckRbf msg; +} LDKMessageSendEvent_LDKSendTxAckRbf_Body; - -/** - * An [`accept_channel`] message to be sent to or received from a peer. - * - * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message - */ -typedef struct MUST_USE_STRUCT LDKAcceptChannel { +typedef struct LDKMessageSendEvent_LDKSendTxAbort_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeAcceptChannel *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKAcceptChannel; - + struct LDKTxAddInput msg; +} LDKMessageSendEvent_LDKSendTxAbort_Body; - -/** - * An [`open_channel`] message to be sent to or received from a peer. - * - * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message - */ -typedef struct MUST_USE_STRUCT LDKOpenChannel { +typedef struct LDKMessageSendEvent_LDKSendChannelReady_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive these message(s) */ - LDKnativeOpenChannel *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The channel_ready message which should be sent. */ - bool is_owned; -} LDKOpenChannel; - - + struct LDKChannelReady msg; +} LDKMessageSendEvent_LDKSendChannelReady_Body; -/** - * A [`funding_created`] message to be sent to or received from a peer. - * - * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message - */ -typedef struct MUST_USE_STRUCT LDKFundingCreated { +typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive these message(s) */ - LDKnativeFundingCreated *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The announcement_signatures message which should be sent. */ - bool is_owned; -} LDKFundingCreated; - - + struct LDKAnnouncementSignatures msg; +} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; -/** - * A [`funding_signed`] message to be sent to or received from a peer. - * - * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message - */ -typedef struct MUST_USE_STRUCT LDKFundingSigned { +typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive these message(s) */ - LDKnativeFundingSigned *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The update messages which should be sent. ALL messages in the struct should be sent! */ - bool is_owned; -} LDKFundingSigned; + struct LDKCommitmentUpdate updates; +} LDKMessageSendEvent_LDKUpdateHTLCs_Body; +typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKRevokeAndACK msg; +} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; +typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKClosingSigned msg; +} LDKMessageSendEvent_LDKSendClosingSigned_Body; -/** - * A [`channel_ready`] message to be sent to or received from a peer. - * - * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message - */ -typedef struct MUST_USE_STRUCT LDKChannelReady { +typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeChannelReady *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKChannelReady; + struct LDKShutdown msg; +} LDKMessageSendEvent_LDKSendShutdown_Body; +typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKChannelReestablish msg; +} LDKMessageSendEvent_LDKSendChannelReestablish_Body; +typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The channel_announcement which should be sent. + */ + struct LDKChannelAnnouncement msg; + /** + * The followup channel_update which should be sent. + */ + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body; -/** - * An [`announcement_signatures`] message to be sent to or received from a peer. - * - * [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message - */ -typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { +typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The channel_announcement which should be sent. */ - LDKnativeAnnouncementSignatures *inner; + struct LDKChannelAnnouncement msg; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The followup channel_update which should be sent. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - bool is_owned; -} LDKAnnouncementSignatures; + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; +typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + /** + * The channel_update which should be sent. + */ + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; +typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { + /** + * The node_announcement which should be sent. + */ + struct LDKNodeAnnouncement msg; +} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; -/** - * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment - * transaction updates if they were pending. - */ -typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { +typedef struct LDKMessageSendEvent_LDKSendChannelUpdate_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeCommitmentUpdate *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The channel_update which should be sent. */ - bool is_owned; -} LDKCommitmentUpdate; + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKSendChannelUpdate_Body; + +typedef struct LDKMessageSendEvent_LDKHandleError_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The action which should be taken. + */ + struct LDKErrorAction action; +} LDKMessageSendEvent_LDKHandleError_Body; +typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { + /** + * The node_id of this message recipient + */ + struct LDKPublicKey node_id; + /** + * The query_channel_range which should be sent. + */ + struct LDKQueryChannelRange msg; +} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; +typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { + /** + * The node_id of this message recipient + */ + struct LDKPublicKey node_id; + /** + * The query_short_channel_ids which should be sent. + */ + struct LDKQueryShortChannelIds msg; +} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; -/** - * A [`revoke_and_ack`] message to be sent to or received from a peer. - * - * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack - */ -typedef struct MUST_USE_STRUCT LDKRevokeAndACK { +typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of this message recipient */ - LDKnativeRevokeAndACK *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The reply_channel_range which should be sent. */ - bool is_owned; -} LDKRevokeAndACK; + struct LDKReplyChannelRange msg; +} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; +typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body { + /** + * The node_id of this message recipient + */ + struct LDKPublicKey node_id; + /** + * The gossip_timestamp_filter which should be sent. + */ + struct LDKGossipTimestampFilter msg; +} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body; +typedef struct MUST_USE_STRUCT LDKMessageSendEvent { + LDKMessageSendEvent_Tag tag; + union { + LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; + LDKMessageSendEvent_LDKSendAcceptChannelV2_Body send_accept_channel_v2; + LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; + LDKMessageSendEvent_LDKSendOpenChannelV2_Body send_open_channel_v2; + LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; + LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; + LDKMessageSendEvent_LDKSendTxAddInput_Body send_tx_add_input; + LDKMessageSendEvent_LDKSendTxAddOutput_Body send_tx_add_output; + LDKMessageSendEvent_LDKSendTxRemoveInput_Body send_tx_remove_input; + LDKMessageSendEvent_LDKSendTxRemoveOutput_Body send_tx_remove_output; + LDKMessageSendEvent_LDKSendTxComplete_Body send_tx_complete; + LDKMessageSendEvent_LDKSendTxSignatures_Body send_tx_signatures; + LDKMessageSendEvent_LDKSendTxInitRbf_Body send_tx_init_rbf; + LDKMessageSendEvent_LDKSendTxAckRbf_Body send_tx_ack_rbf; + LDKMessageSendEvent_LDKSendTxAbort_Body send_tx_abort; + LDKMessageSendEvent_LDKSendChannelReady_Body send_channel_ready; + LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; + LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; + LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; + LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; + LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; + LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; + LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement; + LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; + LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; + LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; + LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update; + LDKMessageSendEvent_LDKHandleError_Body handle_error; + LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; + LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; + LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; + LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; + }; +} LDKMessageSendEvent; /** - * A [`closing_signed`] message to be sent to or received from a peer. - * - * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed + * A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKClosingSigned { +typedef struct LDKCVec_MessageSendEventZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeClosingSigned *inner; + struct LDKMessageSendEvent *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKClosingSigned; + uintptr_t datalen; +} LDKCVec_MessageSendEventZ; /** - * A [`shutdown`] message to be sent to or received from a peer. - * - * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown + * Details about one direction of a channel as received within a [`ChannelUpdate`]. */ -typedef struct MUST_USE_STRUCT LDKShutdown { +typedef struct MUST_USE_STRUCT LDKChannelUpdateInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeShutdown *inner; + LDKnativeChannelUpdateInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKShutdown; - - +} LDKChannelUpdateInfo; /** - * A [`channel_reestablish`] message to be sent to or received from a peer. - * - * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission + * The contents of CResult_ChannelUpdateInfoDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelReestablish { +typedef union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelReestablish *inner; + struct LDKChannelUpdateInfo *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelReestablish; - - + struct LDKDecodeError *err; +} LDKCResult_ChannelUpdateInfoDecodeErrorZPtr; /** - * A [`channel_announcement`] message to be sent to or received from a peer. - * - * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message + * A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { +typedef struct LDKCResult_ChannelUpdateInfoDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelAnnouncement *inner; + union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKChannelAnnouncement; + bool result_ok; +} LDKCResult_ChannelUpdateInfoDecodeErrorZ; /** - * A [`node_announcement`] message to be sent to or received from a peer. - * - * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message + * Details about a channel (both directions). + * Received within a channel announcement. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { +typedef struct MUST_USE_STRUCT LDKChannelInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeAnnouncement *inner; + LDKnativeChannelInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeAnnouncement; - +} LDKChannelInfo; +/** + * The contents of CResult_ChannelInfoDecodeErrorZ + */ +typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelInfoDecodeErrorZPtr; /** - * An [`error`] message to be sent to or received from a peer. - * - * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKErrorMessage { +typedef struct LDKCResult_ChannelInfoDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeErrorMessage *inner; + union LDKCResult_ChannelInfoDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKErrorMessage; + bool result_ok; +} LDKCResult_ChannelInfoDecodeErrorZ; /** - * A [`warning`] message to be sent to or received from a peer. - * - * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + * Fees for routing via a given channel or a node */ -typedef struct MUST_USE_STRUCT LDKWarningMessage { +typedef struct MUST_USE_STRUCT LDKRoutingFees { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeWarningMessage *inner; + LDKnativeRoutingFees *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKWarningMessage; +} LDKRoutingFees; /** - * Used to put an error message in a [`LightningError`]. + * The contents of CResult_RoutingFeesDecodeErrorZ */ -typedef enum LDKErrorAction_Tag { - /** - * The peer took some action which made us think they were useless. Disconnect them. - */ - LDKErrorAction_DisconnectPeer, - /** - * The peer did something harmless that we weren't able to process, just log and ignore - */ - LDKErrorAction_IgnoreError, - /** - * The peer did something harmless that we weren't able to meaningfully process. - * If the error is logged, log it at the given level. - */ - LDKErrorAction_IgnoreAndLog, - /** - * The peer provided us with a gossip message which we'd already seen. In most cases this - * should be ignored, but it may result in the message being forwarded if it is a duplicate of - * our own channel announcements. - */ - LDKErrorAction_IgnoreDuplicateGossip, - /** - * The peer did something incorrect. Tell them. - */ - LDKErrorAction_SendErrorMessage, +typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { /** - * The peer did something incorrect. Tell them without closing any channels. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKErrorAction_SendWarningMessage, + struct LDKRoutingFees *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKErrorAction_Sentinel, -} LDKErrorAction_Tag; + struct LDKDecodeError *err; +} LDKCResult_RoutingFeesDecodeErrorZPtr; -typedef struct LDKErrorAction_LDKDisconnectPeer_Body { +/** + * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RoutingFeesDecodeErrorZ { /** - * An error message which we should make an effort to send before we disconnect. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKDisconnectPeer_Body; - -typedef struct LDKErrorAction_LDKSendErrorMessage_Body { + union LDKCResult_RoutingFeesDecodeErrorZPtr contents; /** - * The message to send. + * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKSendErrorMessage_Body; + bool result_ok; +} LDKCResult_RoutingFeesDecodeErrorZ; -typedef struct LDKErrorAction_LDKSendWarningMessage_Body { +/** + * A 4-byte byte array. + */ +typedef struct LDKFourBytes { /** - * The message to send. + * The four bytes */ - struct LDKWarningMessage msg; + uint8_t data[4]; +} LDKFourBytes; + +/** + * A 12-byte byte array. + */ +typedef struct LDKTwelveBytes { /** - * The peer may have done something harmless that we weren't able to meaningfully process, - * though we should still tell them about it. - * If this event is logged, log it at the given level. + * The twelve bytes */ - enum LDKLevel log_level; -} LDKErrorAction_LDKSendWarningMessage_Body; - -typedef struct MUST_USE_STRUCT LDKErrorAction { - LDKErrorAction_Tag tag; - union { - LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer; - struct { - enum LDKLevel ignore_and_log; - }; - LDKErrorAction_LDKSendErrorMessage_Body send_error_message; - LDKErrorAction_LDKSendWarningMessage_Body send_warning_message; - }; -} LDKErrorAction; + uint8_t data[12]; +} LDKTwelveBytes; /** - * A [`query_channel_range`] message is used to query a peer for channel - * UTXOs in a range of blocks. The recipient of a query makes a best - * effort to reply to the query using one or more [`ReplyChannelRange`] - * messages. + * Represents a hostname for serialization purposes. + * Only the character set and length will be validated. + * The character set consists of ASCII alphanumeric characters, hyphens, and periods. + * Its length is guaranteed to be representable by a single byte. + * This serialization is used by [`BOLT 7`] hostnames. * - * [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages + * [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md */ -typedef struct MUST_USE_STRUCT LDKQueryChannelRange { +typedef struct MUST_USE_STRUCT LDKHostname { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeQueryChannelRange *inner; + LDKnativeHostname *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKQueryChannelRange; - - +} LDKHostname; /** - * A [`query_short_channel_ids`] message is used to query a peer for - * routing gossip messages related to one or more `short_channel_id`s. - * - * The query recipient will reply with the latest, if available, - * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages - * it maintains for the requested `short_channel_id`s followed by a - * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in - * this query are encoded. We only support `encoding_type=0` uncompressed - * serialization and do not support `encoding_type=1` zlib serialization. - * - * [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages + * An address which can be used to connect to a remote peer. */ -typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { +typedef enum LDKNetAddress_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An IPv4 address/port on which the peer is listening. */ - LDKnativeQueryShortChannelIds *inner; + LDKNetAddress_IPv4, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An IPv6 address/port on which the peer is listening. */ - bool is_owned; -} LDKQueryShortChannelIds; - + LDKNetAddress_IPv6, + /** + * An old-style Tor onion address/port on which the peer is listening. + * + * This field is deprecated and the Tor network generally no longer supports V2 Onion + * addresses. Thus, the details are not parsed here. + */ + LDKNetAddress_OnionV2, + /** + * A new-style Tor onion address/port on which the peer is listening. + * + * To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version, + * wrap as base32 and append \".onion\". + */ + LDKNetAddress_OnionV3, + /** + * A hostname/port on which the peer is listening. + */ + LDKNetAddress_Hostname, + /** + * Must be last for serialization purposes + */ + LDKNetAddress_Sentinel, +} LDKNetAddress_Tag; + +typedef struct LDKNetAddress_LDKIPv4_Body { + /** + * The 4-byte IPv4 address + */ + struct LDKFourBytes addr; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKIPv4_Body; + +typedef struct LDKNetAddress_LDKIPv6_Body { + /** + * The 16-byte IPv6 address + */ + struct LDKSixteenBytes addr; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKIPv6_Body; + +typedef struct LDKNetAddress_LDKOnionV3_Body { + /** + * The ed25519 long-term public key of the peer + */ + struct LDKThirtyTwoBytes ed25519_pubkey; + /** + * The checksum of the pubkey and version, as included in the onion address + */ + uint16_t checksum; + /** + * The version byte, as defined by the Tor Onion v3 spec. + */ + uint8_t version; + /** + * The port on which the node is listening + */ + uint16_t port; +} LDKNetAddress_LDKOnionV3_Body; + +typedef struct LDKNetAddress_LDKHostname_Body { + /** + * The hostname on which the node is listening. + */ + struct LDKHostname hostname; + /** + * The port on which the node is listening. + */ + uint16_t port; +} LDKNetAddress_LDKHostname_Body; +typedef struct MUST_USE_STRUCT LDKNetAddress { + LDKNetAddress_Tag tag; + union { + LDKNetAddress_LDKIPv4_Body i_pv4; + LDKNetAddress_LDKIPv6_Body i_pv6; + struct { + struct LDKTwelveBytes onion_v2; + }; + LDKNetAddress_LDKOnionV3_Body onion_v3; + LDKNetAddress_LDKHostname_Body hostname; + }; +} LDKNetAddress; /** - * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`] - * message. - * - * Multiple `reply_channel_range` messages can be sent in reply - * to a single [`QueryChannelRange`] message. The query recipient makes a - * best effort to respond based on their local network view which may - * not be a perfect view of the network. The `short_channel_id`s in the - * reply are encoded. We only support `encoding_type=0` uncompressed - * serialization and do not support `encoding_type=1` zlib serialization. - * - * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages + * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKReplyChannelRange { +typedef struct LDKCVec_NetAddressZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKNetAddress *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_NetAddressZ; + + + +/** + * Information received in the latest node_announcement from this node. + */ +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReplyChannelRange *inner; + LDKnativeNodeAnnouncementInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKReplyChannelRange; +} LDKNodeAnnouncementInfo; + +/** + * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ + */ +typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKNodeAnnouncementInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; + +/** + * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { + /** + * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; /** - * A [`gossip_timestamp_filter`] message is used by a node to request - * gossip relay for messages in the requested time range when the - * `gossip_queries` feature has been negotiated. + * A user-defined name for a node, which may be used when displaying the node in a graph. * - * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message + * Since node aliases are provided by third parties, they are a potential avenue for injection + * attacks. Care must be taken when processing. */ -typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { +typedef struct MUST_USE_STRUCT LDKNodeAlias { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeGossipTimestampFilter *inner; + LDKnativeNodeAlias *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKGossipTimestampFilter; +} LDKNodeAlias; /** - * An event generated by ChannelManager which indicates a message should be sent to a peer (or - * broadcast to most peers). - * These events are handled by PeerManager::process_events if you are using a PeerManager. + * The contents of CResult_NodeAliasDecodeErrorZ */ -typedef enum LDKMessageSendEvent_Tag { +typedef union LDKCResult_NodeAliasDecodeErrorZPtr { /** - * Used to indicate that we've accepted a channel open and should send the accept_channel - * message provided to the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKMessageSendEvent_SendAcceptChannel, + struct LDKNodeAlias *result; /** - * Used to indicate that we've initiated a channel open and should send the open_channel - * message provided to the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKMessageSendEvent_SendOpenChannel, + struct LDKDecodeError *err; +} LDKCResult_NodeAliasDecodeErrorZPtr; + +/** + * A CResult_NodeAliasDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeAlias on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeAliasDecodeErrorZ { /** - * Used to indicate that a funding_created message should be sent to the peer with the given node_id. + * The contents of this CResult_NodeAliasDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKMessageSendEvent_SendFundingCreated, + union LDKCResult_NodeAliasDecodeErrorZPtr contents; /** - * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + * Whether this CResult_NodeAliasDecodeErrorZ represents a success state. */ - LDKMessageSendEvent_SendFundingSigned, + bool result_ok; +} LDKCResult_NodeAliasDecodeErrorZ; + + + +/** + * Details about a node in the network, known from the network announcement. + */ +typedef struct MUST_USE_STRUCT LDKNodeInfo { /** - * Used to indicate that a channel_ready message should be sent to the peer with the given node_id. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMessageSendEvent_SendChannelReady, + LDKnativeNodeInfo *inner; /** - * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMessageSendEvent_SendAnnouncementSignatures, + bool is_owned; +} LDKNodeInfo; + +/** + * The contents of CResult_NodeInfoDecodeErrorZ + */ +typedef union LDKCResult_NodeInfoDecodeErrorZPtr { /** - * Used to indicate that a series of HTLC update messages, as well as a commitment_signed - * message should be sent to the peer with the given node_id. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKMessageSendEvent_UpdateHTLCs, + struct LDKNodeInfo *result; /** - * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKMessageSendEvent_SendRevokeAndACK, + struct LDKDecodeError *err; +} LDKCResult_NodeInfoDecodeErrorZPtr; + +/** + * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeInfoDecodeErrorZ { /** - * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKMessageSendEvent_SendClosingSigned, + union LDKCResult_NodeInfoDecodeErrorZPtr contents; /** - * Used to indicate that a shutdown message should be sent to the peer with the given node_id. + * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. */ - LDKMessageSendEvent_SendShutdown, + bool result_ok; +} LDKCResult_NodeInfoDecodeErrorZ; + +/** + * The contents of CResult_NetworkGraphDecodeErrorZ + */ +typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { /** - * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKMessageSendEvent_SendChannelReestablish, + struct LDKNetworkGraph *result; /** - * Used to send a channel_announcement and channel_update to a specific peer, likely on - * initial connection to ensure our peers know about our channels. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKMessageSendEvent_SendChannelAnnouncement, + struct LDKDecodeError *err; +} LDKCResult_NetworkGraphDecodeErrorZPtr; + +/** + * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::gossip::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NetworkGraphDecodeErrorZ { /** - * Used to indicate that a channel_announcement and channel_update should be broadcast to all - * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). - * - * Note that after doing so, you very likely (unless you did so very recently) want to - * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This - * ensures that any nodes which see our channel_announcement also have a relevant - * node_announcement, including relevant feature flags which may be important for routing - * through or to us. - * - * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement + * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKMessageSendEvent_BroadcastChannelAnnouncement, + union LDKCResult_NetworkGraphDecodeErrorZPtr contents; /** - * Used to indicate that a channel_update should be broadcast to all peers. + * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. */ - LDKMessageSendEvent_BroadcastChannelUpdate, + bool result_ok; +} LDKCResult_NetworkGraphDecodeErrorZ; + +/** + * An enum which can either contain a crate::c_types::derived::CVec_NetAddressZ or not + */ +typedef enum LDKCOption_CVec_NetAddressZZ_Tag { /** - * Used to indicate that a node_announcement should be broadcast to all peers. + * When we're in this state, this COption_CVec_NetAddressZZ contains a crate::c_types::derived::CVec_NetAddressZ */ - LDKMessageSendEvent_BroadcastNodeAnnouncement, + LDKCOption_CVec_NetAddressZZ_Some, /** - * Used to indicate that a channel_update should be sent to a single peer. - * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a - * private channel and we shouldn't be informing all of our peers of channel parameters. + * When we're in this state, this COption_CVec_NetAddressZZ contains nothing */ - LDKMessageSendEvent_SendChannelUpdate, + LDKCOption_CVec_NetAddressZZ_None, /** - * Broadcast an error downstream to be handled + * Must be last for serialization purposes */ - LDKMessageSendEvent_HandleError, + LDKCOption_CVec_NetAddressZZ_Sentinel, +} LDKCOption_CVec_NetAddressZZ_Tag; + +typedef struct LDKCOption_CVec_NetAddressZZ { + LDKCOption_CVec_NetAddressZZ_Tag tag; + union { + struct { + struct LDKCVec_NetAddressZ some; + }; + }; +} LDKCOption_CVec_NetAddressZZ; + +/** + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not + */ +typedef enum LDKCOption_PaymentPreimageZ_Tag { /** - * Query a peer for channels with funding transaction UTXOs in a block range. + * When we're in this state, this COption_PaymentPreimageZ contains a crate::c_types::ThirtyTwoBytes */ - LDKMessageSendEvent_SendChannelRangeQuery, + LDKCOption_PaymentPreimageZ_Some, /** - * Request routing gossip messages from a peer for a list of channels identified by - * their short_channel_ids. + * When we're in this state, this COption_PaymentPreimageZ contains nothing */ - LDKMessageSendEvent_SendShortIdsQuery, + LDKCOption_PaymentPreimageZ_None, /** - * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - * emitted during processing of the query. + * Must be last for serialization purposes */ - LDKMessageSendEvent_SendReplyChannelRange, + LDKCOption_PaymentPreimageZ_Sentinel, +} LDKCOption_PaymentPreimageZ_Tag; + +typedef struct LDKCOption_PaymentPreimageZ { + LDKCOption_PaymentPreimageZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_PaymentPreimageZ; + +/** + * A dynamically-allocated array of crate::lightning::ln::chan_utils::HTLCOutputInCommitments of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_HTLCOutputInCommitmentZ { /** - * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to - * enable receiving gossip messages from the peer. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKMessageSendEvent_SendGossipTimestampFilter, + struct LDKHTLCOutputInCommitment *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKMessageSendEvent_Sentinel, -} LDKMessageSendEvent_Tag; + uintptr_t datalen; +} LDKCVec_HTLCOutputInCommitmentZ; -typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { +/** + * A dynamically-allocated array of crate::lightning::events::bump_transaction::HTLCDescriptors of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_HTLCDescriptorZ { /** - * The node_id of the node which should receive this message + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKHTLCDescriptor *data; /** - * The message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKAcceptChannel msg; -} LDKMessageSendEvent_LDKSendAcceptChannel_Body; + uintptr_t datalen; +} LDKCVec_HTLCDescriptorZ; -typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { + + +/** + * An unspent transaction output that is available to spend resulting from a successful + * [`CoinSelection`] attempt. + */ +typedef struct MUST_USE_STRUCT LDKUtxo { /** - * The node_id of the node which should receive this message + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeUtxo *inner; /** - * The message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKOpenChannel msg; -} LDKMessageSendEvent_LDKSendOpenChannel_Body; + bool is_owned; +} LDKUtxo; -typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { +/** + * A dynamically-allocated array of crate::lightning::events::bump_transaction::Utxos of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UtxoZ { /** - * The node_id of the node which should receive this message + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKUtxo *data; /** - * The message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKFundingCreated msg; -} LDKMessageSendEvent_LDKSendFundingCreated_Body; + uintptr_t datalen; +} LDKCVec_UtxoZ; -typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { +/** + * An enum which can either contain a crate::c_types::TxOut or not + */ +typedef enum LDKCOption_TxOutZ_Tag { /** - * The node_id of the node which should receive this message + * When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut */ - struct LDKPublicKey node_id; + LDKCOption_TxOutZ_Some, /** - * The message which should be sent. + * When we're in this state, this COption_TxOutZ contains nothing */ - struct LDKFundingSigned msg; -} LDKMessageSendEvent_LDKSendFundingSigned_Body; + LDKCOption_TxOutZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_TxOutZ_Sentinel, +} LDKCOption_TxOutZ_Tag; -typedef struct LDKMessageSendEvent_LDKSendChannelReady_Body { +typedef struct LDKCOption_TxOutZ { + LDKCOption_TxOutZ_Tag tag; + union { + struct { + struct LDKTxOut some; + }; + }; +} LDKCOption_TxOutZ; + + + +/** + * An input that must be included in a transaction when performing coin selection through + * [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it + * must have an empty [`TxIn::script_sig`] when spent. + */ +typedef struct MUST_USE_STRUCT LDKInput { /** - * The node_id of the node which should receive these message(s) + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeInput *inner; /** - * The channel_ready message which should be sent. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKChannelReady msg; -} LDKMessageSendEvent_LDKSendChannelReady_Body; + bool is_owned; +} LDKInput; -typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { +/** + * A dynamically-allocated array of crate::lightning::events::bump_transaction::Inputs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_InputZ { /** - * The node_id of the node which should receive these message(s) + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPublicKey node_id; + struct LDKInput *data; /** - * The announcement_signatures message which should be sent. + * The number of elements pointed to by `data`. */ - struct LDKAnnouncementSignatures msg; -} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; + uintptr_t datalen; +} LDKCVec_InputZ; -typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { + + +/** + * The result of a successful coin selection attempt for a transaction requiring additional UTXOs + * to cover its fees. + */ +typedef struct MUST_USE_STRUCT LDKCoinSelection { /** - * The node_id of the node which should receive these message(s) + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey node_id; + LDKnativeCoinSelection *inner; /** - * The update messages which should be sent. ALL messages in the struct should be sent! + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCommitmentUpdate updates; -} LDKMessageSendEvent_LDKUpdateHTLCs_Body; + bool is_owned; +} LDKCoinSelection; -typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { +/** + * The contents of CResult_CoinSelectionNoneZ + */ +typedef union LDKCResult_CoinSelectionNoneZPtr { /** - * The node_id of the node which should receive this message + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey node_id; + struct LDKCoinSelection *result; /** - * The message which should be sent. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKRevokeAndACK msg; -} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; + void *err; +} LDKCResult_CoinSelectionNoneZPtr; -typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { +/** + * A CResult_CoinSelectionNoneZ represents the result of a fallible operation, + * containing a crate::lightning::events::bump_transaction::CoinSelection on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CoinSelectionNoneZ { /** - * The node_id of the node which should receive this message + * The contents of this CResult_CoinSelectionNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey node_id; + union LDKCResult_CoinSelectionNoneZPtr contents; /** - * The message which should be sent. + * Whether this CResult_CoinSelectionNoneZ represents a success state. */ - struct LDKClosingSigned msg; -} LDKMessageSendEvent_LDKSendClosingSigned_Body; + bool result_ok; +} LDKCResult_CoinSelectionNoneZ; -typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { +/** + * The contents of CResult_CVec_UtxoZNoneZ + */ +typedef union LDKCResult_CVec_UtxoZNoneZPtr { /** - * The node_id of the node which should receive this message + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey node_id; + struct LDKCVec_UtxoZ *result; /** - * The message which should be sent. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKShutdown msg; -} LDKMessageSendEvent_LDKSendShutdown_Body; + void *err; +} LDKCResult_CVec_UtxoZNoneZPtr; -typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { +/** + * A CResult_CVec_UtxoZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_UtxoZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CVec_UtxoZNoneZ { /** - * The node_id of the node which should receive this message + * The contents of this CResult_CVec_UtxoZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey node_id; + union LDKCResult_CVec_UtxoZNoneZPtr contents; /** - * The message which should be sent. + * Whether this CResult_CVec_UtxoZNoneZ represents a success state. */ - struct LDKChannelReestablish msg; -} LDKMessageSendEvent_LDKSendChannelReestablish_Body; + bool result_ok; +} LDKCResult_CVec_UtxoZNoneZ; -typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body { +/** + * An enum which can either contain a u16 or not + */ +typedef enum LDKCOption_u16Z_Tag { /** - * The node_id of the node which should receive this message + * When we're in this state, this COption_u16Z contains a u16 */ - struct LDKPublicKey node_id; + LDKCOption_u16Z_Some, /** - * The channel_announcement which should be sent. + * When we're in this state, this COption_u16Z contains nothing */ - struct LDKChannelAnnouncement msg; + LDKCOption_u16Z_None, /** - * The followup channel_update which should be sent. + * Must be last for serialization purposes */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body; + LDKCOption_u16Z_Sentinel, +} LDKCOption_u16Z_Tag; -typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { +typedef struct LDKCOption_u16Z { + LDKCOption_u16Z_Tag tag; + union { + struct { + uint16_t some; + }; + }; +} LDKCOption_u16Z; + +/** + * An enum which can either contain a crate::lightning::ln::channelmanager::ChannelShutdownState or not + */ +typedef enum LDKCOption_ChannelShutdownStateZ_Tag { /** - * The channel_announcement which should be sent. + * When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channelmanager::ChannelShutdownState */ - struct LDKChannelAnnouncement msg; + LDKCOption_ChannelShutdownStateZ_Some, /** - * The followup channel_update which should be sent. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * When we're in this state, this COption_ChannelShutdownStateZ contains nothing */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + LDKCOption_ChannelShutdownStateZ_None, /** - * The channel_update which should be sent. + * Must be last for serialization purposes */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; + LDKCOption_ChannelShutdownStateZ_Sentinel, +} LDKCOption_ChannelShutdownStateZ_Tag; -typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { +typedef struct LDKCOption_ChannelShutdownStateZ { + LDKCOption_ChannelShutdownStateZ_Tag tag; + union { + struct { + enum LDKChannelShutdownState some; + }; + }; +} LDKCOption_ChannelShutdownStateZ; + +/** + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not + */ +typedef enum LDKCOption_PaymentHashZ_Tag { /** - * The node_announcement which should be sent. + * When we're in this state, this COption_PaymentHashZ contains a crate::c_types::ThirtyTwoBytes */ - struct LDKNodeAnnouncement msg; -} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; - -typedef struct LDKMessageSendEvent_LDKSendChannelUpdate_Body { + LDKCOption_PaymentHashZ_Some, /** - * The node_id of the node which should receive this message + * When we're in this state, this COption_PaymentHashZ contains nothing */ - struct LDKPublicKey node_id; + LDKCOption_PaymentHashZ_None, /** - * The channel_update which should be sent. + * Must be last for serialization purposes */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKSendChannelUpdate_Body; + LDKCOption_PaymentHashZ_Sentinel, +} LDKCOption_PaymentHashZ_Tag; -typedef struct LDKMessageSendEvent_LDKHandleError_Body { +typedef struct LDKCOption_PaymentHashZ { + LDKCOption_PaymentHashZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_PaymentHashZ; + +/** + * The contents of CResult__u832APIErrorZ + */ +typedef union LDKCResult__u832APIErrorZPtr { /** - * The node_id of the node which should receive this message + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes *result; /** - * The action which should be taken. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKErrorAction action; -} LDKMessageSendEvent_LDKHandleError_Body; + struct LDKAPIError *err; +} LDKCResult__u832APIErrorZPtr; -typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { +/** + * A CResult__u832APIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult__u832APIErrorZ { /** - * The node_id of this message recipient + * The contents of this CResult__u832APIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey node_id; + union LDKCResult__u832APIErrorZPtr contents; /** - * The query_channel_range which should be sent. + * Whether this CResult__u832APIErrorZ represents a success state. */ - struct LDKQueryChannelRange msg; -} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; + bool result_ok; +} LDKCResult__u832APIErrorZ; -typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { +/** + * Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. + * These include payments that have yet to find a successful path, or have unresolved HTLCs. + */ +typedef enum LDKRecentPaymentDetails_Tag { /** - * The node_id of this message recipient + * When a payment is still being sent and awaiting successful delivery. */ - struct LDKPublicKey node_id; + LDKRecentPaymentDetails_Pending, /** - * The query_short_channel_ids which should be sent. + * When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have + * been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the + * payment is removed from tracking. */ - struct LDKQueryShortChannelIds msg; -} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + LDKRecentPaymentDetails_Fulfilled, + /** + * After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly + * abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all + * pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated. + */ + LDKRecentPaymentDetails_Abandoned, + /** + * Must be last for serialization purposes + */ + LDKRecentPaymentDetails_Sentinel, +} LDKRecentPaymentDetails_Tag; -typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { +typedef struct LDKRecentPaymentDetails_LDKPending_Body { /** - * The node_id of this message recipient + * Hash of the payment that is currently being sent but has yet to be fulfilled or + * abandoned. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes payment_hash; /** - * The reply_channel_range which should be sent. + * Total amount (in msat, excluding fees) across all paths for this payment, + * not just the amount currently inflight. */ - struct LDKReplyChannelRange msg; -} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; + uint64_t total_msat; +} LDKRecentPaymentDetails_LDKPending_Body; -typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body { +typedef struct LDKRecentPaymentDetails_LDKFulfilled_Body { /** - * The node_id of this message recipient + * Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`] + * made before LDK version 0.0.104. */ - struct LDKPublicKey node_id; + struct LDKCOption_PaymentHashZ payment_hash; +} LDKRecentPaymentDetails_LDKFulfilled_Body; + +typedef struct LDKRecentPaymentDetails_LDKAbandoned_Body { /** - * The gossip_timestamp_filter which should be sent. + * Hash of the payment that we have given up trying to send. */ - struct LDKGossipTimestampFilter msg; -} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body; + struct LDKThirtyTwoBytes payment_hash; +} LDKRecentPaymentDetails_LDKAbandoned_Body; -typedef struct MUST_USE_STRUCT LDKMessageSendEvent { - LDKMessageSendEvent_Tag tag; +typedef struct MUST_USE_STRUCT LDKRecentPaymentDetails { + LDKRecentPaymentDetails_Tag tag; union { - LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; - LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; - LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; - LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; - LDKMessageSendEvent_LDKSendChannelReady_Body send_channel_ready; - LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; - LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; - LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; - LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; - LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; - LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; - LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement; - LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; - LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; - LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; - LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update; - LDKMessageSendEvent_LDKHandleError_Body handle_error; - LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; - LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; - LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; - LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; + LDKRecentPaymentDetails_LDKPending_Body pending; + LDKRecentPaymentDetails_LDKFulfilled_Body fulfilled; + LDKRecentPaymentDetails_LDKAbandoned_Body abandoned; }; -} LDKMessageSendEvent; +} LDKRecentPaymentDetails; /** - * A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_MessageSendEventZ { +typedef struct LDKCVec_RecentPaymentDetailsZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKMessageSendEvent *data; + struct LDKRecentPaymentDetails *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_MessageSendEventZ; +} LDKCVec_RecentPaymentDetailsZ; /** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ + * If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one + * of several states. This enum is returned as the Err() type describing which state the payment + * is in, see the description of individual enum states for more. + * + * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route */ -typedef struct LDKCVec_ChainHashZ { +typedef enum LDKPaymentSendFailure_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A parameter which was passed to send_payment was invalid, preventing us from attempting to + * send the payment at all. + * + * You can freely resend the payment in full (with the parameter error fixed). + * + * Because the payment failed outright, no payment tracking is done and no + * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. + * + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ - struct LDKThirtyTwoBytes *data; + LDKPaymentSendFailure_ParameterError, /** - * The number of elements pointed to by `data`. + * A parameter in a single path which was passed to send_payment was invalid, preventing us + * from attempting to send the payment at all. + * + * You can freely resend the payment in full (with the parameter error fixed). + * + * Because the payment failed outright, no payment tracking is done and no + * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. + * + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ - uintptr_t datalen; -} LDKCVec_ChainHashZ; + LDKPaymentSendFailure_PathParameterError, + /** + * All paths which were attempted failed to send, with no channel state change taking place. + * You can freely resend the payment in full (though you probably want to do so over different + * paths than the ones selected). + * + * Because the payment failed outright, no payment tracking is done and no + * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. + * + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + */ + LDKPaymentSendFailure_AllFailedResendSafe, + /** + * Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not + * yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). + * + * [`PaymentId`]: crate::ln::channelmanager::PaymentId + * [`Event::PaymentSent`]: crate::events::Event::PaymentSent + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + */ + LDKPaymentSendFailure_DuplicatePayment, + /** + * Some paths that were attempted failed to send, though some paths may have succeeded. At least + * some paths have irrevocably committed to the HTLC. + * + * The results here are ordered the same as the paths in the route object that was passed to + * send_payment. + * + * Any entries that contain `Err(APIError::MonitorUpdateInprogress)` will send once a + * [`MonitorEvent::Completed`] is provided for the next-hop channel with the latest update_id. + * + * [`MonitorEvent::Completed`]: crate::chain::channelmonitor::MonitorEvent::Completed + */ + LDKPaymentSendFailure_PartialFailure, + /** + * Must be last for serialization purposes + */ + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; + +typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body { + /** + * The errors themselves, in the same order as the paths from the route. + */ + struct LDKCVec_CResult_NoneAPIErrorZZ results; + /** + * If some paths failed without irrevocably committing to the new HTLC(s), this will + * contain a [`RouteParameters`] object for the failing paths. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKRouteParameters failed_paths_retry; + /** + * The payment id for the payment, which is now at least partially pending. + */ + struct LDKThirtyTwoBytes payment_id; +} LDKPaymentSendFailure_LDKPartialFailure_Body; + +typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { + LDKPaymentSendFailure_Tag tag; + union { + struct { + struct LDKAPIError parameter_error; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; + }; + struct { + struct LDKCVec_APIErrorZ all_failed_resend_safe; + }; + LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure; + }; +} LDKPaymentSendFailure; /** - * The contents of CResult_PublicKeyErrorZ + * The contents of CResult_NonePaymentSendFailureZ */ -typedef union LDKCResult_PublicKeyErrorZPtr { +typedef union LDKCResult_NonePaymentSendFailureZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKPublicKey *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSecp256k1Error *err; -} LDKCResult_PublicKeyErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_NonePaymentSendFailureZPtr; /** - * A CResult_PublicKeyErrorZ represents the result of a fallible operation, - * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PublicKeyErrorZ { +typedef struct LDKCResult_NonePaymentSendFailureZ { /** - * The contents of this CResult_PublicKeyErrorZ, accessible via either + * The contents of this CResult_NonePaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PublicKeyErrorZPtr contents; + union LDKCResult_NonePaymentSendFailureZPtr contents; /** - * Whether this CResult_PublicKeyErrorZ represents a success state. + * Whether this CResult_NonePaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_PublicKeyErrorZ; +} LDKCResult_NonePaymentSendFailureZ; /** - * The contents of CResult_NodeIdDecodeErrorZ + * The contents of CResult_NoneRetryableSendFailureZ */ -typedef union LDKCResult_NodeIdDecodeErrorZPtr { +typedef union LDKCResult_NoneRetryableSendFailureZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKNodeId *result; + void *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_NodeIdDecodeErrorZPtr; + enum LDKRetryableSendFailure *err; +} LDKCResult_NoneRetryableSendFailureZPtr; /** - * A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::NodeId on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeIdDecodeErrorZ { +typedef struct LDKCResult_NoneRetryableSendFailureZ { /** - * The contents of this CResult_NodeIdDecodeErrorZ, accessible via either + * The contents of this CResult_NoneRetryableSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeIdDecodeErrorZPtr contents; + union LDKCResult_NoneRetryableSendFailureZPtr contents; /** - * Whether this CResult_NodeIdDecodeErrorZ represents a success state. + * Whether this CResult_NoneRetryableSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_NodeIdDecodeErrorZ; +} LDKCResult_NoneRetryableSendFailureZ; /** - * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ + * The contents of CResult_PaymentHashPaymentSendFailureZ */ -typedef union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr { +typedef union LDKCResult_PaymentHashPaymentSendFailureZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_NetworkUpdateZ *result; + struct LDKThirtyTwoBytes *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_PaymentHashPaymentSendFailureZPtr; /** - * A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ { +typedef struct LDKCResult_PaymentHashPaymentSendFailureZ { /** - * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents; + union LDKCResult_PaymentHashPaymentSendFailureZPtr contents; /** - * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. + * Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_COption_NetworkUpdateZDecodeErrorZ; +} LDKCResult_PaymentHashPaymentSendFailureZ; /** - * The contents of CResult_TxOutUtxoLookupErrorZ + * The contents of CResult_PaymentHashRetryableSendFailureZ */ -typedef union LDKCResult_TxOutUtxoLookupErrorZPtr { +typedef union LDKCResult_PaymentHashRetryableSendFailureZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTxOut *result; + struct LDKThirtyTwoBytes *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKUtxoLookupError *err; -} LDKCResult_TxOutUtxoLookupErrorZPtr; + enum LDKRetryableSendFailure *err; +} LDKCResult_PaymentHashRetryableSendFailureZPtr; /** - * A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, - * containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. + * A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TxOutUtxoLookupErrorZ { +typedef struct LDKCResult_PaymentHashRetryableSendFailureZ { /** - * The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either + * The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TxOutUtxoLookupErrorZPtr contents; + union LDKCResult_PaymentHashRetryableSendFailureZPtr contents; /** - * Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. + * Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_TxOutUtxoLookupErrorZ; - - +} LDKCResult_PaymentHashRetryableSendFailureZ; /** - * Represents a future resolution of a [`UtxoLookup::get_utxo`] query resolving async. - * - * See [`UtxoResult::Async`] and [`UtxoFuture::resolve`] for more info. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKUtxoFuture { +typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeUtxoFuture *inner; + struct LDKThirtyTwoBytes a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKUtxoFuture; + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentIdZ; /** - * The result of a [`UtxoLookup::get_utxo`] call. A call may resolve either synchronously, - * returning the `Sync` variant, or asynchronously, returning an [`UtxoFuture`] in the `Async` - * variant. + * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ */ -typedef enum LDKUtxoResult_Tag { - /** - * A result which was resolved synchronously. It either includes a [`TxOut`] for the output - * requested or a [`UtxoLookupError`]. - */ - LDKUtxoResult_Sync, +typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { /** - * A result which will be resolved asynchronously. It includes a [`UtxoFuture`], a `clone` of - * which you must keep locally and call [`UtxoFuture::resolve`] on once the lookup completes. - * - * Note that in order to avoid runaway memory usage, the number of parallel checks is limited, - * but only fairly loosely. Because a pending checks block all message processing, leaving - * checks pending for an extended time may cause DoS of other functions. It is recommended you - * keep a tight timeout on lookups, on the order of a few seconds. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKUtxoResult_Async, + struct LDKC2Tuple_PaymentHashPaymentIdZ *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKUtxoResult_Sentinel, -} LDKUtxoResult_Tag; - -typedef struct MUST_USE_STRUCT LDKUtxoResult { - LDKUtxoResult_Tag tag; - union { - struct { - struct LDKCResult_TxOutUtxoLookupErrorZ sync; - }; - struct { - struct LDKUtxoFuture async; - }; - }; -} LDKUtxoResult; + struct LDKPaymentSendFailure *err; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; /** - * The `UtxoLookup` trait defines behavior for accessing on-chain UTXOs. + * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKUtxoLookup { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { /** - * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. - * Returns an error if `genesis_hash` is for a different chain or if such a transaction output - * is unknown. - * - * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id + * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKUtxoResult (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); + union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. */ - void (*free)(void *this_arg); -} LDKUtxoLookup; + bool result_ok; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; /** - * An enum which can either contain a crate::lightning::routing::utxo::UtxoLookup or not + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKCOption_UtxoLookupZ_Tag { +typedef struct LDKCVec_ThirtyTwoBytesZ { /** - * When we're in this state, this COption_UtxoLookupZ contains a crate::lightning::routing::utxo::UtxoLookup + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_UtxoLookupZ_Some, + struct LDKThirtyTwoBytes *data; /** - * When we're in this state, this COption_UtxoLookupZ contains nothing + * The number of elements pointed to by `data`. */ - LDKCOption_UtxoLookupZ_None, + uintptr_t datalen; +} LDKCVec_ThirtyTwoBytesZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { /** - * Must be last for serialization purposes + * The element at position 0 */ - LDKCOption_UtxoLookupZ_Sentinel, -} LDKCOption_UtxoLookupZ_Tag; - -typedef struct LDKCOption_UtxoLookupZ { - LDKCOption_UtxoLookupZ_Tag tag; - union { - struct { - struct LDKUtxoLookup some; - }; - }; -} LDKCOption_UtxoLookupZ; + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentSecretZ; /** - * The contents of CResult_boolLightningErrorZ + * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ */ -typedef union LDKCResult_boolLightningErrorZPtr { +typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - bool *result; + struct LDKC2Tuple_PaymentHashPaymentSecretZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKLightningError *err; -} LDKCResult_boolLightningErrorZPtr; + void *err; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr; /** - * A CResult_boolLightningErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. + * A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_boolLightningErrorZ { +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { /** - * The contents of this CResult_boolLightningErrorZ, accessible via either + * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_boolLightningErrorZPtr contents; + union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents; /** - * Whether this CResult_boolLightningErrorZ represents a success state. + * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_boolLightningErrorZ; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * The contents of CResult_PaymentSecretNoneZ */ -typedef struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - /** - * The element at position 0 - */ - struct LDKChannelAnnouncement a; +typedef union LDKCResult_PaymentSecretNoneZPtr { /** - * The element at position 1 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelUpdate b; + struct LDKThirtyTwoBytes *result; /** - * The element at position 2 + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKChannelUpdate c; -} LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; + void *err; +} LDKCResult_PaymentSecretNoneZPtr; /** - * An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not + * A CResult_PaymentSecretNoneZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag { - /** - * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ - */ - LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some, +typedef struct LDKCResult_PaymentSecretNoneZ { /** - * When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing + * The contents of this CResult_PaymentSecretNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None, + union LDKCResult_PaymentSecretNoneZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_PaymentSecretNoneZ represents a success state. */ - LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Sentinel, -} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag; - -typedef struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Tag tag; - union { - struct { - struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ some; - }; - }; -} LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; + bool result_ok; +} LDKCResult_PaymentSecretNoneZ; /** - * The contents of CResult_NoneLightningErrorZ + * The contents of CResult_PaymentPreimageAPIErrorZ */ -typedef union LDKCResult_NoneLightningErrorZPtr { +typedef union LDKCResult_PaymentPreimageAPIErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKThirtyTwoBytes *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKLightningError *err; -} LDKCResult_NoneLightningErrorZPtr; + struct LDKAPIError *err; +} LDKCResult_PaymentPreimageAPIErrorZPtr; /** - * A CResult_NoneLightningErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. + * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneLightningErrorZ { +typedef struct LDKCResult_PaymentPreimageAPIErrorZ { /** - * The contents of this CResult_NoneLightningErrorZ, accessible via either + * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneLightningErrorZPtr contents; + union LDKCResult_PaymentPreimageAPIErrorZPtr contents; /** - * Whether this CResult_NoneLightningErrorZ represents a success state. + * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneLightningErrorZ; +} LDKCResult_PaymentPreimageAPIErrorZ; + +/** + * An enum which can either contain a crate::c_types::derived::CVec_ChainHashZ or not + */ +typedef enum LDKCOption_CVec_ChainHashZZ_Tag { + /** + * When we're in this state, this COption_CVec_ChainHashZZ contains a crate::c_types::derived::CVec_ChainHashZ + */ + LDKCOption_CVec_ChainHashZZ_Some, + /** + * When we're in this state, this COption_CVec_ChainHashZZ contains nothing + */ + LDKCOption_CVec_ChainHashZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_CVec_ChainHashZZ_Sentinel, +} LDKCOption_CVec_ChainHashZZ_Tag; + +typedef struct LDKCOption_CVec_ChainHashZZ { + LDKCOption_CVec_ChainHashZZ_Tag tag; + union { + struct { + struct LDKCVec_ChainHashZ some; + }; + }; +} LDKCOption_CVec_ChainHashZZ; /** - * Details about one direction of a channel as received within a [`ChannelUpdate`]. + * Information needed for constructing an invoice route hint for this channel. */ -typedef struct MUST_USE_STRUCT LDKChannelUpdateInfo { +typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelUpdateInfo *inner; + LDKnativeCounterpartyForwardingInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelUpdateInfo; +} LDKCounterpartyForwardingInfo; /** - * The contents of CResult_ChannelUpdateInfoDecodeErrorZ + * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ */ -typedef union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr { +typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelUpdateInfo *result; + struct LDKCounterpartyForwardingInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelUpdateInfoDecodeErrorZPtr; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; /** - * A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelUpdateInfoDecodeErrorZ { +typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { /** - * The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either + * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr contents; + union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. + * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelUpdateInfoDecodeErrorZ; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; /** - * Details about a channel (both directions). - * Received within a channel announcement. + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. */ -typedef struct MUST_USE_STRUCT LDKChannelInfo { +typedef struct MUST_USE_STRUCT LDKChannelCounterparty { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelInfo *inner; + LDKnativeChannelCounterparty *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelInfo; +} LDKChannelCounterparty; /** - * The contents of CResult_ChannelInfoDecodeErrorZ + * The contents of CResult_ChannelCounterpartyDecodeErrorZ */ -typedef union LDKCResult_ChannelInfoDecodeErrorZPtr { +typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelInfo *result; + struct LDKChannelCounterparty *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelInfoDecodeErrorZPtr; +} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; /** - * A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelInfoDecodeErrorZ { +typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { /** - * The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelInfoDecodeErrorZPtr contents; + union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. + * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelInfoDecodeErrorZ; - - - -/** - * Fees for routing via a given channel or a node - */ -typedef struct MUST_USE_STRUCT LDKRoutingFees { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRoutingFees *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRoutingFees; +} LDKCResult_ChannelCounterpartyDecodeErrorZ; /** - * The contents of CResult_RoutingFeesDecodeErrorZ + * The contents of CResult_ChannelDetailsDecodeErrorZ */ -typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { +typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRoutingFees *result; + struct LDKChannelDetails *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_RoutingFeesDecodeErrorZPtr; +} LDKCResult_ChannelDetailsDecodeErrorZPtr; /** - * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RoutingFeesDecodeErrorZ { +typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { /** - * The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RoutingFeesDecodeErrorZPtr contents; + union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; /** - * Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RoutingFeesDecodeErrorZ; - -/** - * A 4-byte byte array. - */ -typedef struct LDKFourBytes { - /** - * The four bytes - */ - uint8_t data[4]; -} LDKFourBytes; - -/** - * A 12-byte byte array. - */ -typedef struct LDKTwelveBytes { - /** - * The twelve bytes - */ - uint8_t data[12]; -} LDKTwelveBytes; +} LDKCResult_ChannelDetailsDecodeErrorZ; /** - * Represents a hostname for serialization purposes. - * Only the character set and length will be validated. - * The character set consists of ASCII alphanumeric characters, hyphens, and periods. - * Its length is guaranteed to be representable by a single byte. - * This serialization is used by [`BOLT 7`] hostnames. + * Route hints used in constructing invoices for [phantom node payents]. * - * [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md + * [phantom node payments]: crate::sign::PhantomKeysManager */ -typedef struct MUST_USE_STRUCT LDKHostname { +typedef struct MUST_USE_STRUCT LDKPhantomRouteHints { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeHostname *inner; + LDKnativePhantomRouteHints *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKHostname; - -/** - * An address which can be used to connect to a remote peer. - */ -typedef enum LDKNetAddress_Tag { - /** - * An IPv4 address/port on which the peer is listening. - */ - LDKNetAddress_IPv4, - /** - * An IPv6 address/port on which the peer is listening. - */ - LDKNetAddress_IPv6, - /** - * An old-style Tor onion address/port on which the peer is listening. - * - * This field is deprecated and the Tor network generally no longer supports V2 Onion - * addresses. Thus, the details are not parsed here. - */ - LDKNetAddress_OnionV2, - /** - * A new-style Tor onion address/port on which the peer is listening. - * - * To create the human-readable \"hostname\", concatenate the ED25519 pubkey, checksum, and version, - * wrap as base32 and append \".onion\". - */ - LDKNetAddress_OnionV3, - /** - * A hostname/port on which the peer is listening. - */ - LDKNetAddress_Hostname, - /** - * Must be last for serialization purposes - */ - LDKNetAddress_Sentinel, -} LDKNetAddress_Tag; - -typedef struct LDKNetAddress_LDKIPv4_Body { - /** - * The 4-byte IPv4 address - */ - struct LDKFourBytes addr; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKIPv4_Body; - -typedef struct LDKNetAddress_LDKIPv6_Body { - /** - * The 16-byte IPv6 address - */ - struct LDKSixteenBytes addr; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKIPv6_Body; - -typedef struct LDKNetAddress_LDKOnionV3_Body { - /** - * The ed25519 long-term public key of the peer - */ - struct LDKThirtyTwoBytes ed25519_pubkey; - /** - * The checksum of the pubkey and version, as included in the onion address - */ - uint16_t checksum; - /** - * The version byte, as defined by the Tor Onion v3 spec. - */ - uint8_t version; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKOnionV3_Body; - -typedef struct LDKNetAddress_LDKHostname_Body { - /** - * The hostname on which the node is listening. - */ - struct LDKHostname hostname; - /** - * The port on which the node is listening. - */ - uint16_t port; -} LDKNetAddress_LDKHostname_Body; - -typedef struct MUST_USE_STRUCT LDKNetAddress { - LDKNetAddress_Tag tag; - union { - LDKNetAddress_LDKIPv4_Body i_pv4; - LDKNetAddress_LDKIPv6_Body i_pv6; - struct { - struct LDKTwelveBytes onion_v2; - }; - LDKNetAddress_LDKOnionV3_Body onion_v3; - LDKNetAddress_LDKHostname_Body hostname; - }; -} LDKNetAddress; +} LDKPhantomRouteHints; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_PhantomRouteHintsDecodeErrorZ */ -typedef struct LDKCVec_NetAddressZ { +typedef union LDKCResult_PhantomRouteHintsDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNetAddress *data; + struct LDKPhantomRouteHints *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_NetAddressZ; - - + struct LDKDecodeError *err; +} LDKCResult_PhantomRouteHintsDecodeErrorZPtr; /** - * Information received in the latest node_announcement from this node. + * A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeNodeAnnouncementInfo *inner; + union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKNodeAnnouncementInfo; + bool result_ok; +} LDKCResult_PhantomRouteHintsDecodeErrorZ; /** - * The contents of CResult_NodeAnnouncementInfoDecodeErrorZ + * The contents of CResult_ChannelShutdownStateDecodeErrorZ */ -typedef union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr { +typedef union LDKCResult_ChannelShutdownStateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeAnnouncementInfo *result; + enum LDKChannelShutdownState *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr; +} LDKCResult_ChannelShutdownStateDecodeErrorZPtr; /** - * A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ { +typedef struct LDKCResult_ChannelShutdownStateDecodeErrorZ { /** - * The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeAnnouncementInfoDecodeErrorZPtr contents; + union LDKCResult_ChannelShutdownStateDecodeErrorZPtr contents; /** - * Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + * Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeAnnouncementInfoDecodeErrorZ; +} LDKCResult_ChannelShutdownStateDecodeErrorZ; /** - * A user-defined name for a node, which may be used when displaying the node in a graph. + * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates + * on-chain transactions to ensure no loss of funds occurs. * - * Since node aliases are provided by third parties, they are a potential avenue for injection - * attacks. Care must be taken when processing. + * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date + * information and are actively monitoring the chain. + * + * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! */ -typedef struct MUST_USE_STRUCT LDKNodeAlias { +typedef struct MUST_USE_STRUCT LDKChannelMonitor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeAlias *inner; + LDKnativeChannelMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeAlias; - -/** - * The contents of CResult_NodeAliasDecodeErrorZ - */ -typedef union LDKCResult_NodeAliasDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNodeAlias *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_NodeAliasDecodeErrorZPtr; +} LDKChannelMonitor; /** - * A CResult_NodeAliasDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::NodeAlias on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_NodeAliasDecodeErrorZ { +typedef struct LDKCVec_ChannelMonitorZ { /** - * The contents of this CResult_NodeAliasDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_NodeAliasDecodeErrorZPtr contents; + struct LDKChannelMonitor *data; /** - * Whether this CResult_NodeAliasDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_NodeAliasDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_ChannelMonitorZ; /** - * Details about a node in the network, known from the network announcement. + * An update generated by the underlying channel itself which contains some new information the + * [`ChannelMonitor`] should be made aware of. + * + * Because this represents only a small number of updates to the underlying state, it is generally + * much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction + * updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment + * transaction), a single update may reach upwards of 1 MiB in serialized size. */ -typedef struct MUST_USE_STRUCT LDKNodeInfo { +typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeInfo *inner; + LDKnativeChannelMonitorUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeInfo; +} LDKChannelMonitorUpdate; /** - * The contents of CResult_NodeInfoDecodeErrorZ - */ -typedef union LDKCResult_NodeInfoDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNodeInfo *result; + * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as + * blocks are connected and disconnected. + * + * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are + * responsible for maintaining a set of monitors such that they can be updated accordingly as + * channel state changes and HTLCs are resolved. See method documentation for specific + * requirements. + * + * Implementations **must** ensure that updates are successfully applied and persisted upon method + * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down + * without taking any further action such as persisting the current state. + * + * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing + * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it + * could result in a revoked transaction being broadcast, allowing the counterparty to claim all + * funds in the channel. See [`ChannelMonitorUpdateStatus`] for more details about how to handle + * multiple instances. + * + * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure + */ +typedef struct LDKWatch { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKDecodeError *err; -} LDKCResult_NodeInfoDecodeErrorZPtr; - -/** - * A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NodeInfoDecodeErrorZ { + void *this_arg; /** - * The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Watches a channel identified by `funding_txo` using `monitor`. + * + * Implementations are responsible for watching the chain for the funding transaction along + * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * + * Note: this interface MUST error with [`ChannelMonitorUpdateStatus::PermanentFailure`] if + * the given `funding_txo` has previously been registered via `watch_channel`. + * + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected */ - union LDKCResult_NodeInfoDecodeErrorZPtr contents; + enum LDKChannelMonitorUpdateStatus (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); /** - * Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor */ - bool result_ok; -} LDKCResult_NodeInfoDecodeErrorZ; - -/** - * The contents of CResult_NetworkGraphDecodeErrorZ - */ -typedef union LDKCResult_NetworkGraphDecodeErrorZPtr { + enum LDKChannelMonitorUpdateStatus (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update); /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * 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::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. */ - struct LDKNetworkGraph *result; + struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ (*release_pending_monitor_events)(const void *this_arg); /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - struct LDKDecodeError *err; -} LDKCResult_NetworkGraphDecodeErrorZPtr; + void (*free)(void *this_arg); +} LDKWatch; /** - * A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_NetworkGraphDecodeErrorZ { +typedef struct LDKCVec_TransactionZ { /** - * The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_NetworkGraphDecodeErrorZPtr contents; + struct LDKTransaction *data; /** - * Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_NetworkGraphDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_TransactionZ; /** - * An enum which can either contain a crate::c_types::derived::CVec_NetAddressZ or not + * An interface to send a transaction to the Bitcoin network. */ -typedef enum LDKCOption_CVec_NetAddressZZ_Tag { +typedef struct LDKBroadcasterInterface { /** - * When we're in this state, this COption_CVec_NetAddressZZ contains a crate::c_types::derived::CVec_NetAddressZ + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKCOption_CVec_NetAddressZZ_Some, + void *this_arg; /** - * When we're in this state, this COption_CVec_NetAddressZZ contains nothing + * Sends a list of transactions out to (hopefully) be mined. + * This only needs to handle the actual broadcasting of transactions, LDK will automatically + * rebroadcast transactions that haven't made it into a block. + * + * In some cases LDK may attempt to broadcast a transaction which double-spends another + * and this isn't a bug and can be safely ignored. + * + * If more than one transaction is given, these transactions should be considered to be a + * package and broadcast together. Some of the transactions may or may not depend on each other, + * be sure to manage both cases correctly. + * + * Bitcoin transaction packages are defined in BIP 331 and here: + * https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md */ - LDKCOption_CVec_NetAddressZZ_None, + void (*broadcast_transactions)(const void *this_arg, struct LDKCVec_TransactionZ txs); /** - * Must be last for serialization purposes + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - LDKCOption_CVec_NetAddressZZ_Sentinel, -} LDKCOption_CVec_NetAddressZZ_Tag; - -typedef struct LDKCOption_CVec_NetAddressZZ { - LDKCOption_CVec_NetAddressZZ_Tag tag; - union { - struct { - struct LDKCVec_NetAddressZ some; - }; - }; -} LDKCOption_CVec_NetAddressZZ; + void (*free)(void *this_arg); +} LDKBroadcasterInterface; /** - * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ + * A trait that describes a source of entropy. */ -typedef union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKDelayedPaymentOutputDescriptor *result; +typedef struct LDKEntropySource { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKDecodeError *err; -} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr; - -/** - * A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + void *this_arg; /** - * The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a + * different value each time it is called. */ - union LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); /** - * Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool result_ok; -} LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ; + void (*free)(void *this_arg); +} LDKEntropySource; /** - * The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ + * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not + * own the memory pointed to by data. */ -typedef union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +typedef struct LDKu8slice { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the byte buffer */ - struct LDKStaticPaymentOutputDescriptor *result; + const uint8_t *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of bytes pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr; + uintptr_t datalen; +} LDKu8slice; + + /** - * A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * The unsigned part of a [`channel_update`] message. + * + * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message */ -typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { /** - * The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZPtr contents; + LDKnativeUnsignedChannelUpdate *inner; /** - * Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ; + bool is_owned; +} LDKUnsignedChannelUpdate; + + /** - * The contents of CResult_SpendableOutputDescriptorDecodeErrorZ + * The unsigned part of a [`node_announcement`] message. + * + * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message */ -typedef union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKSpendableOutputDescriptor *result; + LDKnativeUnsignedNodeAnnouncement *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr; + bool is_owned; +} LDKUnsignedNodeAnnouncement; /** - * A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Represents the set of gossip messages that require a signature from a node's identity key. */ -typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { +typedef enum LDKUnsignedGossipMessage_Tag { /** - * The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An unsigned channel announcement. */ - union LDKCResult_SpendableOutputDescriptorDecodeErrorZPtr contents; + LDKUnsignedGossipMessage_ChannelAnnouncement, /** - * Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + * An unsigned channel update. */ - bool result_ok; -} LDKCResult_SpendableOutputDescriptorDecodeErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_PaymentPreimageZ { + LDKUnsignedGossipMessage_ChannelUpdate, /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * An unsigned node announcement. */ - struct LDKThirtyTwoBytes *data; + LDKUnsignedGossipMessage_NodeAnnouncement, /** - * The number of elements pointed to by `data`. + * Must be last for serialization purposes */ - uintptr_t datalen; -} LDKCVec_PaymentPreimageZ; + LDKUnsignedGossipMessage_Sentinel, +} LDKUnsignedGossipMessage_Tag; + +typedef struct MUST_USE_STRUCT LDKUnsignedGossipMessage { + LDKUnsignedGossipMessage_Tag tag; + union { + struct { + struct LDKUnsignedChannelAnnouncement channel_announcement; + }; + struct { + struct LDKUnsignedChannelUpdate channel_update; + }; + struct { + struct LDKUnsignedNodeAnnouncement node_announcement; + }; + }; +} LDKUnsignedGossipMessage; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A trait that can handle cryptographic operations at the scope level of a node. */ -typedef struct LDKC2Tuple_SignatureCVec_SignatureZZ { +typedef struct LDKNodeSigner { /** - * The element at position 0 + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKSignature a; + void *this_arg; /** - * The element at position 1 + * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. + * + * If the implementor of this trait supports [phantom node payments], then every node that is + * intended to be included in the phantom invoice route hints must return the same value from + * this method. + * + * This method must return the same value each time it is called. + * + * [phantom node payments]: PhantomKeysManager */ - struct LDKCVec_SignatureZ b; -} LDKC2Tuple_SignatureCVec_SignatureZZ; - -/** - * The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ - */ -typedef union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + struct LDKThirtyTwoBytes (*get_inbound_payment_key_material)(const void *this_arg); /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Get node id based on the provided [`Recipient`]. + * + * This method must return the same value each time it is called with a given [`Recipient`] + * parameter. + * + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - struct LDKC2Tuple_SignatureCVec_SignatureZZ *result; + struct LDKCResult_PublicKeyNoneZ (*get_node_id)(const void *this_arg, enum LDKRecipient recipient); /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if + * one is provided. Note that this tweak can be applied to `other_key` instead of our node + * secret, though this is less efficient. + * + * Note that if this fails while attempting to forward an HTLC, LDK will panic. The error + * should be resolved to allow LDK to resume forwarding HTLCs. + * + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - void *err; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr; - -/** - * A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + struct LDKCResult_SharedSecretNoneZ (*ecdh)(const void *this_arg, enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak); /** - * The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Sign an invoice. + * + * By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of + * this trait to parse the invoice and make sure they're signing what they expect, rather than + * blindly signing the hash. + * + * The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. + * + * The secret key used to sign the invoice is dependent on the [`Recipient`]. + * + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - union LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr contents; + struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); /** - * Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + * Sign a gossip message. + * + * Note that if this fails, LDK may panic and the message will not be broadcast to the network + * or a possible channel counterparty. If LDK panics, the error should be resolved to allow the + * message to be broadcast, as otherwise it may prevent one from receiving funds over the + * corresponding channel. */ - bool result_ok; -} LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; + struct LDKCResult_SignatureNoneZ (*sign_gossip_message)(const void *this_arg, struct LDKUnsignedGossipMessage msg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKNodeSigner; /** - * The contents of CResult_SignatureNoneZ + * A trait that can return signer instances for individual channels. */ -typedef union LDKCResult_SignatureNoneZPtr { +typedef struct LDKSignerProvider { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKSignature *result; + void *this_arg; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through + * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow + * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated + * `channel_keys_id`. + * + * This method must return a different value each time it is called. */ - void *err; -} LDKCResult_SignatureNoneZPtr; - -/** - * A CResult_SignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Signature on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_SignatureNoneZ { + struct LDKThirtyTwoBytes (*generate_channel_keys_id)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis, struct LDKU128 user_channel_id); /** - * The contents of this CResult_SignatureNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Derives the private key material backing a `Signer`. + * + * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through + * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be + * re-derived from its `channel_keys_id`, which can be obtained through its trait method + * [`ChannelSigner::channel_keys_id`]. */ - union LDKCResult_SignatureNoneZPtr contents; + struct LDKWriteableEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** - * Whether this CResult_SignatureNoneZ represents a success state. + * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. + * This is only called during deserialization of other objects which contain + * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. + * + * This method is slowly being phased out -- it will only be called when reading objects + * written by LDK versions prior to 0.0.113. + * + * [`Signer`]: Self::Signer + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - bool result_ok; -} LDKCResult_SignatureNoneZ; - -/** - * The contents of CResult_PublicKeyNoneZ - */ -typedef union LDKCResult_PublicKeyNoneZPtr { + struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + * + * If this function returns an error, this will result in a channel failing to open. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - struct LDKPublicKey *result; + struct LDKCResult_ScriptNoneZ (*get_destination_script)(const void *this_arg); /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Get a script pubkey which we will send funds to when closing a channel. + * + * If this function returns an error, this will result in a channel failing to open or close. + * In the event of a failure when the counterparty is initiating a close, this can result in a + * channel force close. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - void *err; -} LDKCResult_PublicKeyNoneZPtr; + struct LDKCResult_ShutdownScriptNoneZ (*get_shutdown_scriptpubkey)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSignerProvider; /** - * A CResult_PublicKeyNoneZ represents the result of a fallible operation, - * containing a crate::c_types::PublicKey on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A trait which should be implemented to provide feerate information on a number of time + * horizons. + * + * If access to a local mempool is not feasible, feerate estimates should be fetched from a set of + * third-parties hosting them. Note that this enables them to affect the propagation of your + * pre-signed transactions at any time and therefore endangers the safety of channels funds. It + * should be considered carefully as a deployment. + * + * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're + * called from inside the library in response to chain events, P2P events, or timer events). */ -typedef struct LDKCResult_PublicKeyNoneZ { +typedef struct LDKFeeEstimator { /** - * The contents of this CResult_PublicKeyNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - union LDKCResult_PublicKeyNoneZPtr contents; + void *this_arg; /** - * Whether this CResult_PublicKeyNoneZ represents a success state. + * Gets estimated satoshis of fee required per 1000 Weight-Units. + * + * LDK will wrap this method and ensure that the value returned is no smaller than 253 + * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte). + * + * The following unit conversions can be used to convert to sats/KW: + * * satoshis-per-byte * 250 + * * satoshis-per-kbyte / 4 */ - bool result_ok; -} LDKCResult_PublicKeyNoneZ; + uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFeeEstimator; /** - * An enum which can either contain a crate::c_types::BigEndianScalar or not + * A trait defining behavior for routing a payment. */ -typedef enum LDKCOption_ScalarZ_Tag { +typedef struct LDKRouter { /** - * When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKCOption_ScalarZ_Some, + void *this_arg; /** - * When we're in this state, this COption_ScalarZ contains nothing + * Finds a [`Route`] for a payment between the given `payer` and a payee. + * + * The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + * and [`RouteParameters::final_value_msat`], respectively. + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKCOption_ScalarZ_None, + struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs); /** - * Must be last for serialization purposes + * Finds a [`Route`] for a payment between the given `payer` and a payee. + * + * The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + * and [`RouteParameters::final_value_msat`], respectively. + * + * Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific + * payment. + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKCOption_ScalarZ_Sentinel, -} LDKCOption_ScalarZ_Tag; + struct LDKCResult_RouteLightningErrorZ (*find_route_with_id)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKRouter; + -typedef struct LDKCOption_ScalarZ { - LDKCOption_ScalarZ_Tag tag; - union { - struct { - struct LDKBigEndianScalar some; - }; - }; -} LDKCOption_ScalarZ; /** - * The contents of CResult_SharedSecretNoneZ + * Manager which keeps track of a number of channels and sends messages to the appropriate + * channel, also tracking HTLC preimages and forwarding onion packets appropriately. + * + * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through + * to individual Channels. + * + * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for + * all peers during write/read (though does not modify this instance, only the instance being + * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e., + * called [`funding_transaction_generated`] for outbound channels) being closed. + * + * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with + * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST write each monitor update out to disk before + * returning from [`chain::Watch::watch_channel`]/[`update_channel`], with ChannelManagers, writing updates + * happens out-of-band (and will prevent any other `ChannelManager` operations from occurring during + * the serialization process). If the deserialized version is out-of-date compared to the + * [`ChannelMonitor`] passed by reference to [`read`], those channels will be force-closed based on the + * `ChannelMonitor` state and no funds will be lost (mod on-chain transaction fees). + * + * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which + * tells you the last block hash which was connected. You should get the best block tip before using the manager. + * See [`chain::Listen`] and [`chain::Confirm`] for more details. + * + * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating + * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid + * spam due to quick disconnection/reconnection, updates are not sent until the channel has been + * offline for a full minute. In order to track this, you must call + * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect. + * + * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and + * inbound channels without confirmed funding transactions. This may result in nodes which we do + * not have a channel with being unable to connect to us or open new channels with us if we have + * many peers with unfunded channels. + * + * Because it is an indication of trust, inbound channels which we've accepted as 0conf are + * exempted from the count of unfunded channels. Similarly, outbound channels and connections are + * never limited. Please ensure you limit the count of such channels yourself. + * + * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`] + * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but + * essentially you should default to using a [`SimpleRefChannelManager`], and use a + * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when + * you're using lightning-net-tokio. + * + * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected + * [`funding_created`]: msgs::FundingCreated + * [`funding_transaction_generated`]: Self::funding_transaction_generated + * [`BlockHash`]: bitcoin::hash_types::BlockHash + * [`update_channel`]: chain::Watch::update_channel + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`timer_tick_occurred`]: Self::timer_tick_occurred + * [`read`]: ReadableArgs::read */ -typedef union LDKCResult_SharedSecretNoneZPtr { +typedef struct MUST_USE_STRUCT LDKChannelManager { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes *result; + LDKnativeChannelManager *inner; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void *err; -} LDKCResult_SharedSecretNoneZPtr; + bool is_owned; +} LDKChannelManager; /** - * A CResult_SharedSecretNoneZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_SharedSecretNoneZ { +typedef struct LDKC2Tuple_BlockHashChannelManagerZ { /** - * The contents of this CResult_SharedSecretNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_SharedSecretNoneZPtr contents; + struct LDKThirtyTwoBytes a; /** - * Whether this CResult_SharedSecretNoneZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_SharedSecretNoneZ; + struct LDKChannelManager b; +} LDKC2Tuple_BlockHashChannelManagerZ; /** - * Integer in the range `0..32` + * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ */ -typedef struct LDKU5 { - uint8_t _0; -} LDKU5; +typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC2Tuple_BlockHashChannelManagerZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::U5s of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_U5Z { +typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKU5 *data; + union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_U5Z; + bool result_ok; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; /** - * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which - * allows recovering the exact public key which created the signature given the message. + * Options for how to set the max dust HTLC exposure allowed on a channel. See + * [`ChannelConfig::max_dust_htlc_exposure`] for details. */ -typedef struct LDKRecoverableSignature { +typedef enum LDKMaxDustHTLCExposure_Tag { /** - * The bytes of the signature in "compact" form plus a "Recovery ID" which allows for - * recovery. + * This sets a fixed limit on the total dust exposure in millisatoshis. Setting this too low + * may prevent the sending or receipt of low-value HTLCs on high-traffic nodes, however this + * limit is very important to prevent stealing of large amounts of dust HTLCs by miners + * through [fee griefing + * attacks](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html). + * + * Note that if the feerate increases significantly, without a manual increase + * to this maximum the channel may be unable to send/receive HTLCs between the maximum dust + * exposure and the new minimum value for HTLCs to be economically viable to claim. */ - uint8_t serialized_form[68]; -} LDKRecoverableSignature; + LDKMaxDustHTLCExposure_FixedLimitMsat, + /** + * This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from + * [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used + * then the maximum dust exposure in millisatoshis is calculated as: + * `high_priority_feerate_per_kw * value`. For example, with our default value + * `FeeRateMultiplier(5000)`: + * + * - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum + * defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + * be 253 * 5000 = 1,265,000 msats. + * - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be + * 7500 * 5000 = 37,500,000 msats. + * + * This allows the maximum dust exposure to automatically scale with fee rate changes. + * + * Note, if you're using a third-party fee estimator, this may leave you more exposed to a + * fee griefing attack, where your fee estimator may purposely overestimate the fee rate, + * causing you to accept more dust HTLCs than you would otherwise. + * + * This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included + * on HTLC outputs means your channel may be subject to more dust exposure in the event of + * increases in fee rate. + * + * # Backwards Compatibility + * This variant only became available in LDK 0.0.116, so if you downgrade to a prior version + * by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. + * + * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + */ + LDKMaxDustHTLCExposure_FeeRateMultiplier, + /** + * Must be last for serialization purposes + */ + LDKMaxDustHTLCExposure_Sentinel, +} LDKMaxDustHTLCExposure_Tag; + +typedef struct MUST_USE_STRUCT LDKMaxDustHTLCExposure { + LDKMaxDustHTLCExposure_Tag tag; + union { + struct { + uint64_t fixed_limit_msat; + }; + struct { + uint64_t fee_rate_multiplier; + }; + }; +} LDKMaxDustHTLCExposure; /** - * The contents of CResult_RecoverableSignatureNoneZ + * The contents of CResult_MaxDustHTLCExposureDecodeErrorZ */ -typedef union LDKCResult_RecoverableSignatureNoneZPtr { +typedef union LDKCResult_MaxDustHTLCExposureDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRecoverableSignature *result; + struct LDKMaxDustHTLCExposure *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_RecoverableSignatureNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_MaxDustHTLCExposureDecodeErrorZPtr; /** - * A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::RecoverableSignature on success and a () on failure. + * A CResult_MaxDustHTLCExposureDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::config::MaxDustHTLCExposure on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RecoverableSignatureNoneZ { +typedef struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ { /** - * The contents of this CResult_RecoverableSignatureNoneZ, accessible via either + * The contents of this CResult_MaxDustHTLCExposureDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RecoverableSignatureNoneZPtr contents; + union LDKCResult_MaxDustHTLCExposureDecodeErrorZPtr contents; /** - * Whether this CResult_RecoverableSignatureNoneZ represents a success state. + * Whether this CResult_MaxDustHTLCExposureDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RecoverableSignatureNoneZ; +} LDKCResult_MaxDustHTLCExposureDecodeErrorZ; /** - * This class tracks the per-transaction information needed to build a closing transaction and will - * actually build it and sign. - * - * This class can be used inside a signer implementation to generate a signature given the relevant - * secret key. + * Options which apply on a per-channel basis and may change at runtime or based on negotiation + * with our counterparty. */ -typedef struct MUST_USE_STRUCT LDKClosingTransaction { +typedef struct MUST_USE_STRUCT LDKChannelConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeClosingTransaction *inner; + LDKnativeChannelConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKClosingTransaction; - - +} LDKChannelConfig; /** - * The unsigned part of a [`channel_announcement`] message. - * - * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message + * The contents of CResult_ChannelConfigDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement { +typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeUnsignedChannelAnnouncement *inner; + struct LDKChannelConfig *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKUnsignedChannelAnnouncement; + struct LDKDecodeError *err; +} LDKCResult_ChannelConfigDecodeErrorZPtr; /** - * A trait to handle Lightning channel key material without concretizing the channel type or - * the signature mechanism. + * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKChannelSigner { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Gets the per-commitment point for a specific commitment number - * - * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); - /** - * Gets the commitment secret for a specific commitment number as part of the revocation process - * - * An external signer implementation should error here if the commitment was already signed - * and should refuse to sign it in the future. - * - * May be called more than once for the same index. - * - * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - */ - struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); - /** - * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. - * - * This is required in order for the signer to make sure that releasing a commitment - * secret won't leave us without a broadcastable holder transaction. - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * Note that all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. - */ - struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); - /** - * Returns the holder's channel public keys and basepoints. - */ - LDKChannelPublicKeys pubkeys; - /** - * Fill in the pubkeys field as a reference to it will be given to Rust after this returns - * Note that this takes a pointer to this object, not the this_ptr like other methods do - * This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. - */ - void (*set_pubkeys)(const struct LDKChannelSigner*NONNULL_PTR ); - /** - * Returns an arbitrary identifier describing the set of keys which are provided back to you in - * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this - * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. - */ - struct LDKThirtyTwoBytes (*channel_keys_id)(const void *this_arg); +typedef struct LDKCResult_ChannelConfigDecodeErrorZ { /** - * Set the counterparty static channel data, including basepoints, - * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. - * - * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] - * instance, LDK will call this method exactly once - either immediately after construction - * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding - * information has been generated. - * - * channel_parameters.is_populated() MUST be true. + * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*provide_channel_parameters)(void *this_arg, const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + union LDKCResult_ChannelConfigDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKChannelSigner; + bool result_ok; +} LDKCResult_ChannelConfigDecodeErrorZ; /** - * A trait to sign Lightning channel transactions as described in - * [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). - * - * Signing services could be implemented on a hardware wallet and should implement signing - * policies in order to be secure. Please refer to the [VLS Policy - * Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) - * for an example of such policies. + * An enum which can either contain a crate::lightning::util::config::MaxDustHTLCExposure or not */ -typedef struct LDKEcdsaChannelSigner { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - * - * Note that if signing fails or is rejected, the channel will be force-closed. - * - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * Note that all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. - */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); - /** - * Validate the counterparty's revocation. - * - * This is required in order for the signer to make sure that the state has moved - * forward and it is safe to sign the next counterparty commitment. - */ - struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]); - /** - * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. - * - * This will be called - * - with a non-revoked `commitment_tx`. - * - with the latest `commitment_tx` when we initiate a force-close. - * - with the previous `commitment_tx`, just to get claiming HTLC - * signatures, if we are reacting to a [`ChannelMonitor`] - * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) - * that decided to broadcast before it had been updated to the latest `commitment_tx`. - * - * This may be called multiple times for the same transaction. - * - * An external signer implementation should check that the commitment has not been revoked. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_holder_commitment_and_htlcs)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); - /** - * Create a signature for the given input in a transaction spending an HTLC transaction output - * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. - * - * `per_commitment_key` is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do - * so). - */ - struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); - /** - * Create a signature for the given input in a transaction spending a commitment transaction - * HTLC output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * `amount` is the value of the output spent by this input, committed to in the BIP 143 - * signature. - * - * `per_commitment_key` is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder revocation_secret to do - * so). - * - * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script - * (which is committed to in the BIP 143 signatures). - */ - struct LDKCResult_SignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); - /** - * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - * transaction, either offered or received. - * - * Such a transaction may claim multiples offered outputs at same time if we know the - * preimage for each when we create it, but only the input at index `input` should be - * signed for here. It may be called multiple times for same output(s) if a fee-bump is - * needed with regards to an upcoming timelock expiration. - * - * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC - * outputs. - * - * `amount` is value of the output spent by this input, committed to in the BIP 143 signature. - * - * `per_commitment_point` is the dynamic point corresponding to the channel state - * detected onchain. It has been generated by our counterparty and is used to derive - * channel state keys, which are then included in the witness script and committed to in the - * BIP 143 signature. - */ - struct LDKCResult_SignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); - /** - * Create a signature for a (proposed) closing transaction. - * - * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have - * chosen to forgo their output as dust. - */ - struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); +typedef enum LDKCOption_MaxDustHTLCExposureZ_Tag { /** - * Computes the signature for a commitment transaction's anchor output used as an - * input within `anchor_tx`, which spends the commitment transaction, at index `input`. - */ - struct LDKCResult_SignatureNoneZ (*sign_holder_anchor_input)(const void *this_arg, struct LDKTransaction anchor_tx, uintptr_t input); - /** - * Signs a channel announcement message with our funding key proving it comes from one of the - * channel participants. - * - * Channel announcements also require a signature from each node's network key. Our node - * signature is computed through [`NodeSigner::sign_gossip_message`]. - * - * Note that if this fails or is rejected, the channel will not be publicly announced and - * our counterparty may (though likely will not) close the channel on us for violating the - * protocol. + * When we're in this state, this COption_MaxDustHTLCExposureZ contains a crate::lightning::util::config::MaxDustHTLCExposure */ - struct LDKCResult_SignatureNoneZ (*sign_channel_announcement_with_funding_key)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + LDKCOption_MaxDustHTLCExposureZ_Some, /** - * Implementation of ChannelSigner for this object. + * When we're in this state, this COption_MaxDustHTLCExposureZ contains nothing */ - struct LDKChannelSigner ChannelSigner; + LDKCOption_MaxDustHTLCExposureZ_None, /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Must be last for serialization purposes */ - void (*free)(void *this_arg); -} LDKEcdsaChannelSigner; + LDKCOption_MaxDustHTLCExposureZ_Sentinel, +} LDKCOption_MaxDustHTLCExposureZ_Tag; + +typedef struct LDKCOption_MaxDustHTLCExposureZ { + LDKCOption_MaxDustHTLCExposureZ_Tag tag; + union { + struct { + struct LDKMaxDustHTLCExposure some; + }; + }; +} LDKCOption_MaxDustHTLCExposureZ; /** - * A writeable signer. - * - * There will always be two instances of a signer per channel, one occupied by the - * [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * An enum which can either contain a crate::lightning::util::errors::APIError or not */ -typedef struct LDKWriteableEcdsaChannelSigner { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef enum LDKCOption_APIErrorZ_Tag { /** - * Implementation of EcdsaChannelSigner for this object. + * When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError */ - struct LDKEcdsaChannelSigner EcdsaChannelSigner; + LDKCOption_APIErrorZ_Some, /** - * Serialize the object into a byte array + * When we're in this state, this COption_APIErrorZ contains nothing */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + LDKCOption_APIErrorZ_None, /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Must be last for serialization purposes */ - void (*free)(void *this_arg); -} LDKWriteableEcdsaChannelSigner; + LDKCOption_APIErrorZ_Sentinel, +} LDKCOption_APIErrorZ_Tag; + +typedef struct LDKCOption_APIErrorZ { + LDKCOption_APIErrorZ_Tag tag; + union { + struct { + struct LDKAPIError some; + }; + }; +} LDKCOption_APIErrorZ; /** - * The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ + * The contents of CResult_COption_APIErrorZDecodeErrorZ */ -typedef union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +typedef union LDKCResult_COption_APIErrorZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKWriteableEcdsaChannelSigner *result; + struct LDKCOption_APIErrorZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr; +} LDKCResult_COption_APIErrorZDecodeErrorZPtr; /** - * A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ { +typedef struct LDKCResult_COption_APIErrorZDecodeErrorZ { /** - * The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either + * The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr contents; + union LDKCResult_COption_APIErrorZDecodeErrorZPtr contents; /** - * Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. + * Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ; +} LDKCResult_COption_APIErrorZDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ */ -typedef struct LDKCVec_CVec_u8ZZ { +typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_CVec_u8ZZ; - -/** - * The contents of CResult_CVec_CVec_u8ZZNoneZ - */ -typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKCVec_CVec_u8ZZ *result; + struct LDKChannelMonitorUpdate *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_CVec_CVec_u8ZZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; /** - * A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. + * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ { +typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { /** - * The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents; + union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_CVec_u8ZZNoneZ; - - +} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; /** - * A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. - * - * This implementation performs no policy checks and is insufficient by itself as - * a secure external signer. + * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not */ -typedef struct MUST_USE_STRUCT LDKInMemorySigner { +typedef enum LDKCOption_MonitorEventZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent */ - LDKnativeInMemorySigner *inner; + LDKCOption_MonitorEventZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_MonitorEventZ contains nothing */ - bool is_owned; -} LDKInMemorySigner; + LDKCOption_MonitorEventZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_MonitorEventZ_Sentinel, +} LDKCOption_MonitorEventZ_Tag; + +typedef struct LDKCOption_MonitorEventZ { + LDKCOption_MonitorEventZ_Tag tag; + union { + struct { + struct LDKMonitorEvent some; + }; + }; +} LDKCOption_MonitorEventZ; /** - * The contents of CResult_InMemorySignerDecodeErrorZ + * The contents of CResult_COption_MonitorEventZDecodeErrorZ */ -typedef union LDKCResult_InMemorySignerDecodeErrorZPtr { +typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInMemorySigner *result; + struct LDKCOption_MonitorEventZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InMemorySignerDecodeErrorZPtr; +} LDKCResult_COption_MonitorEventZDecodeErrorZPtr; /** - * A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InMemorySignerDecodeErrorZ { +typedef struct LDKCResult_COption_MonitorEventZDecodeErrorZ { /** - * The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either + * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InMemorySignerDecodeErrorZPtr contents; + union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents; /** - * Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InMemorySignerDecodeErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_TxOutZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKTxOut *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_TxOutZ; +} LDKCResult_COption_MonitorEventZDecodeErrorZ; /** - * The contents of CResult_TransactionNoneZ + * The contents of CResult_HTLCUpdateDecodeErrorZ */ -typedef union LDKCResult_TransactionNoneZPtr { +typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKTransaction *result; + struct LDKHTLCUpdate *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_TransactionNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_HTLCUpdateDecodeErrorZPtr; /** - * A CResult_TransactionNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Transaction on success and a () on failure. + * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_TransactionNoneZ { +typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { /** - * The contents of this CResult_TransactionNoneZ, accessible via either + * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_TransactionNoneZPtr contents; + union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_TransactionNoneZ represents a success state. + * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_TransactionNoneZ; - - +} LDKCResult_HTLCUpdateDecodeErrorZ; /** - * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates - * on-chain transactions to ensure no loss of funds occurs. - * - * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date - * information and are actively monitoring the chain. - * - * Pending Events or updated HTLCs which have not yet been read out by - * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and - * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events - * gotten are fully handled before re-serializing the new state. - * - * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the - * returned block hash and the the current chain and then reconnecting blocks to get to the - * best chain) upon deserializing the object! + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKChannelMonitor { +typedef struct LDKC2Tuple_OutPointScriptZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeChannelMonitor *inner; + struct LDKOutPoint a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKChannelMonitor; + struct LDKCVec_u8Z b; +} LDKC2Tuple_OutPointScriptZ; /** * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { +typedef struct LDKC2Tuple_u32ScriptZ { /** * The element at position 0 */ - struct LDKThirtyTwoBytes a; + uint32_t a; /** * The element at position 1 */ - struct LDKChannelMonitor b; -} LDKC2Tuple_BlockHashChannelMonitorZ; + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *data; + struct LDKC2Tuple_u32ScriptZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; +} LDKCVec_C2Tuple_u32ScriptZZ; /** - * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; + struct LDKThirtyTwoBytes a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - enum LDKIOError *err; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; /** - * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { /** - * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; /** - * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; /** - * An enum which can either contain a u16 or not + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKCOption_u16Z_Tag { +typedef struct LDKC2Tuple_u32TxOutZ { /** - * When we're in this state, this COption_u16Z contains a u16 + * The element at position 0 */ - LDKCOption_u16Z_Some, + uint32_t a; /** - * When we're in this state, this COption_u16Z contains nothing + * The element at position 1 */ - LDKCOption_u16Z_None, + struct LDKTxOut b; +} LDKC2Tuple_u32TxOutZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_u32TxOutZZ { /** - * Must be last for serialization purposes + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_u16Z_Sentinel, -} LDKCOption_u16Z_Tag; - -typedef struct LDKCOption_u16Z { - LDKCOption_u16Z_Tag tag; - union { - struct { - uint16_t some; - }; - }; -} LDKCOption_u16Z; + struct LDKC2Tuple_u32TxOutZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_u32TxOutZZ; /** - * The contents of CResult__u832APIErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult__u832APIErrorZPtr { +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKThirtyTwoBytes *result; + struct LDKThirtyTwoBytes a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKAPIError *err; -} LDKCResult__u832APIErrorZPtr; + struct LDKCVec_C2Tuple_u32TxOutZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; /** - * A CResult__u832APIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult__u832APIErrorZ { +typedef struct LDKCVec_TransactionOutputsZ { /** - * The contents of this CResult__u832APIErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult__u832APIErrorZPtr contents; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; /** - * Whether this CResult__u832APIErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult__u832APIErrorZ; + uintptr_t datalen; +} LDKCVec_TransactionOutputsZ; /** - * Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. - * These include payments that have yet to find a successful path, or have unresolved HTLCs. + * Details about the balance(s) available for spending once the channel appears on chain. + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not + * be provided. */ -typedef enum LDKRecentPaymentDetails_Tag { +typedef enum LDKBalance_Tag { /** - * When a payment is still being sent and awaiting successful delivery. + * The channel is not yet closed (or the commitment or closing transaction has not yet + * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is + * force-closed now. */ - LDKRecentPaymentDetails_Pending, + LDKBalance_ClaimableOnChannelClose, /** - * When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have - * been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the - * payment is removed from tracking. + * The channel has been closed, and the given balance is ours but awaiting confirmations until + * we consider it spendable. */ - LDKRecentPaymentDetails_Fulfilled, + LDKBalance_ClaimableAwaitingConfirmations, /** - * After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly - * abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all - * pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated. + * The channel has been closed, and the given balance should be ours but awaiting spending + * transaction confirmation. If the spending transaction does not confirm in time, it is + * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain. + * + * Once the spending transaction confirms, before it has reached enough confirmations to be + * considered safe from chain reorganizations, the balance will instead be provided via + * [`Balance::ClaimableAwaitingConfirmations`]. */ - LDKRecentPaymentDetails_Abandoned, + LDKBalance_ContentiousClaimable, + /** + * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain + * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat + * likely to be claimed by our counterparty before we do. + */ + LDKBalance_MaybeTimeoutClaimableHTLC, + /** + * HTLCs which we received from our counterparty which are claimable with a preimage which we + * do not currently have. This will only be claimable if we receive the preimage from the node + * to which we forwarded this HTLC before the timeout. + */ + LDKBalance_MaybePreimageClaimableHTLC, + /** + * The channel has been closed, and our counterparty broadcasted a revoked commitment + * transaction. + * + * Thus, we're able to claim all outputs in the commitment transaction, one of which has the + * following amount. + */ + LDKBalance_CounterpartyRevokedOutputClaimable, /** * Must be last for serialization purposes */ - LDKRecentPaymentDetails_Sentinel, -} LDKRecentPaymentDetails_Tag; + LDKBalance_Sentinel, +} LDKBalance_Tag; -typedef struct LDKRecentPaymentDetails_LDKPending_Body { +typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { /** - * Hash of the payment that is currently being sent but has yet to be fulfilled or - * abandoned. + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. + */ + uint64_t claimable_amount_satoshis; +} LDKBalance_LDKClaimableOnChannelClose_Body; + +typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { + /** + * The amount available to claim, in satoshis, possibly excluding the on-chain fees which + * were spent in broadcasting the transaction. + */ + uint64_t claimable_amount_satoshis; + /** + * The height at which an [`Event::SpendableOutputs`] event will be generated for this + * amount. + */ + uint32_t confirmation_height; +} LDKBalance_LDKClaimableAwaitingConfirmations_Body; + +typedef struct LDKBalance_LDKContentiousClaimable_Body { + /** + * The amount available to claim, in satoshis, excluding the on-chain fees which will be + * required to do so. + */ + uint64_t claimable_amount_satoshis; + /** + * The height at which the counterparty may be able to claim the balance if we have not + * done so. + */ + uint32_t timeout_height; + /** + * The payment hash that locks this HTLC. */ struct LDKThirtyTwoBytes payment_hash; /** - * Total amount (in msat, excluding fees) across all paths for this payment, - * not just the amount currently inflight. + * The preimage that can be used to claim this HTLC. */ - uint64_t total_msat; -} LDKRecentPaymentDetails_LDKPending_Body; + struct LDKThirtyTwoBytes payment_preimage; +} LDKBalance_LDKContentiousClaimable_Body; -typedef struct LDKRecentPaymentDetails_LDKFulfilled_Body { +typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { /** - * Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`] - * made before LDK version 0.0.104. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The amount potentially available to claim, in satoshis, excluding the on-chain fees + * which will be required to do so. + */ + uint64_t claimable_amount_satoshis; + /** + * The height at which we will be able to claim the balance if our counterparty has not + * done so. + */ + uint32_t claimable_height; + /** + * The payment hash whose preimage our counterparty needs to claim this HTLC. */ struct LDKThirtyTwoBytes payment_hash; -} LDKRecentPaymentDetails_LDKFulfilled_Body; +} LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; -typedef struct LDKRecentPaymentDetails_LDKAbandoned_Body { +typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { /** - * Hash of the payment that we have given up trying to send. + * The amount potentially available to claim, in satoshis, excluding the on-chain fees + * which will be required to do so. + */ + uint64_t claimable_amount_satoshis; + /** + * The height at which our counterparty will be able to claim the balance if we have not + * yet received the preimage and claimed it ourselves. + */ + uint32_t expiry_height; + /** + * The payment hash whose preimage we need to claim this HTLC. */ struct LDKThirtyTwoBytes payment_hash; -} LDKRecentPaymentDetails_LDKAbandoned_Body; +} LDKBalance_LDKMaybePreimageClaimableHTLC_Body; -typedef struct MUST_USE_STRUCT LDKRecentPaymentDetails { - LDKRecentPaymentDetails_Tag tag; +typedef struct LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body { + /** + * The amount, in satoshis, of the output which we can claim. + * + * Note that for outputs from HTLC balances this may be excluding some on-chain fees that + * were already spent. + */ + uint64_t claimable_amount_satoshis; +} LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body; + +typedef struct MUST_USE_STRUCT LDKBalance { + LDKBalance_Tag tag; union { - LDKRecentPaymentDetails_LDKPending_Body pending; - LDKRecentPaymentDetails_LDKFulfilled_Body fulfilled; - LDKRecentPaymentDetails_LDKAbandoned_Body abandoned; + LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close; + LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations; + LDKBalance_LDKContentiousClaimable_Body contentious_claimable; + LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body maybe_timeout_claimable_htlc; + LDKBalance_LDKMaybePreimageClaimableHTLC_Body maybe_preimage_claimable_htlc; + LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body counterparty_revoked_output_claimable; }; -} LDKRecentPaymentDetails; +} LDKBalance; /** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_RecentPaymentDetailsZ { +typedef struct LDKCVec_BalanceZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKRecentPaymentDetails *data; + struct LDKBalance *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_RecentPaymentDetailsZ; +} LDKCVec_BalanceZ; /** - * If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one - * of several states. This enum is returned as the Err() type describing which state the payment - * is in, see the description of individual enum states for more. - * - * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKPaymentSendFailure_Tag { +typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { /** - * A parameter which was passed to send_payment was invalid, preventing us from attempting to - * send the payment at all. - * - * You can freely resend the payment in full (with the parameter error fixed). - * - * Because the payment failed outright, no payment tracking is done and no - * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. - * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + * The element at position 0 */ - LDKPaymentSendFailure_ParameterError, + struct LDKThirtyTwoBytes a; /** - * A parameter in a single path which was passed to send_payment was invalid, preventing us - * from attempting to send the payment at all. - * - * You can freely resend the payment in full (with the parameter error fixed). - * - * Because the payment failed outright, no payment tracking is done and no - * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment. - * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + * The element at position 1 */ - LDKPaymentSendFailure_PathParameterError, + struct LDKChannelMonitor b; +} LDKC2Tuple_BlockHashChannelMonitorZ; + +/** + * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /** - * All paths which were attempted failed to send, with no channel state change taking place. - * You can freely resend the payment in full (though you probably want to do so over different - * paths than the ones selected). - * - * Because the payment failed outright, no payment tracking is done and no - * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. - * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentSendFailure_AllFailedResendSafe, + struct LDKC2Tuple_BlockHashChannelMonitorZ *result; /** - * Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not - * yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). - * - * [`PaymentId`]: crate::ln::channelmanager::PaymentId - * [`Event::PaymentSent`]: crate::events::Event::PaymentSent - * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKPaymentSendFailure_DuplicatePayment, + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; + +/** + * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { /** - * Some paths that were attempted failed to send, though some paths may have succeeded. At least - * some paths have irrevocably committed to the HTLC. - * - * The results here are ordered the same as the paths in the route object that was passed to - * send_payment. - * - * Any entries that contain `Err(APIError::MonitorUpdateInprogress)` will send once a - * [`MonitorEvent::Completed`] is provided for the next-hop channel with the latest update_id. - * - * [`MonitorEvent::Completed`]: crate::chain::channelmonitor::MonitorEvent::Completed + * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKPaymentSendFailure_PartialFailure, + union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. */ - LDKPaymentSendFailure_Sentinel, -} LDKPaymentSendFailure_Tag; + bool result_ok; +} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; -typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body { +/** + * Defines a type identifier for sending messages over the wire. + * + * Messages implementing this trait specify a type and must be [`Writeable`]. + */ +typedef struct LDKType { /** - * The errors themselves, in the same order as the paths from the route. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKCVec_CResult_NoneAPIErrorZZ results; + void *this_arg; /** - * If some paths failed without irrevocably committing to the new HTLC(s), this will - * contain a [`RouteParameters`] object for the failing paths. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns the type identifying the message payload. */ - struct LDKRouteParameters failed_paths_retry; + uint16_t (*type_id)(const void *this_arg); /** - * The payment id for the payment, which is now at least partially pending. + * Return a human-readable "debug" string describing this object */ - struct LDKThirtyTwoBytes payment_id; -} LDKPaymentSendFailure_LDKPartialFailure_Body; + struct LDKStr (*debug_str)(const void *this_arg); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKType; -typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { - LDKPaymentSendFailure_Tag tag; - union { - struct { - struct LDKAPIError parameter_error; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; - }; - struct { - struct LDKCVec_APIErrorZ all_failed_resend_safe; - }; - LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure; - }; -} LDKPaymentSendFailure; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_PublicKeyTypeZ { + /** + * The element at position 0 + */ + struct LDKPublicKey a; + /** + * The element at position 1 + */ + struct LDKType b; +} LDKC2Tuple_PublicKeyTypeZ; /** - * The contents of CResult_NonePaymentSendFailureZ + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_NonePaymentSendFailureZPtr { +typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void *result; + struct LDKC2Tuple_PublicKeyTypeZ *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_NonePaymentSendFailureZPtr; + uintptr_t datalen; +} LDKCVec_C2Tuple_PublicKeyTypeZZ; + + /** - * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. + * + * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request + * specifies these such that its recipient can send an invoice for payment. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Offer`]: crate::offers::offer::Offer */ -typedef struct LDKCResult_NonePaymentSendFailureZ { +typedef struct MUST_USE_STRUCT LDKInvoiceRequest { /** - * The contents of this CResult_NonePaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_NonePaymentSendFailureZPtr contents; + LDKnativeInvoiceRequest *inner; /** - * Whether this CResult_NonePaymentSendFailureZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_NonePaymentSendFailureZ; + bool is_owned; +} LDKInvoiceRequest; + + /** - * The contents of CResult_NoneRetryableSendFailureZ + * A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`]. + * + * An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent + * directly after scanning a refund. It includes all the information needed to pay a recipient. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -typedef union LDKCResult_NoneRetryableSendFailureZPtr { +typedef struct MUST_USE_STRUCT LDKBolt12Invoice { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *result; + LDKnativeBolt12Invoice *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - enum LDKRetryableSendFailure *err; -} LDKCResult_NoneRetryableSendFailureZPtr; + bool is_owned; +} LDKBolt12Invoice; + + /** - * A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An error in response to an [`InvoiceRequest`] or an [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -typedef struct LDKCResult_NoneRetryableSendFailureZ { +typedef struct MUST_USE_STRUCT LDKInvoiceError { /** - * The contents of this CResult_NoneRetryableSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_NoneRetryableSendFailureZPtr contents; + LDKnativeInvoiceError *inner; /** - * Whether this CResult_NoneRetryableSendFailureZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_NoneRetryableSendFailureZ; + bool is_owned; +} LDKInvoiceError; /** - * The contents of CResult_PaymentHashPaymentSendFailureZ + * Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`]. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage */ -typedef union LDKCResult_PaymentHashPaymentSendFailureZPtr { +typedef enum LDKOffersMessage_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A request for a [`Bolt12Invoice`] for a particular [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer */ - struct LDKThirtyTwoBytes *result; + LDKOffersMessage_InvoiceRequest, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * A [`Bolt12Invoice`] sent in response to an [`InvoiceRequest`] or a [`Refund`]. + * + * [`Refund`]: crate::offers::refund::Refund */ - struct LDKPaymentSendFailure *err; -} LDKCResult_PaymentHashPaymentSendFailureZPtr; + LDKOffersMessage_Invoice, + /** + * An error from handling an [`OffersMessage`]. + */ + LDKOffersMessage_InvoiceError, + /** + * Must be last for serialization purposes + */ + LDKOffersMessage_Sentinel, +} LDKOffersMessage_Tag; + +typedef struct MUST_USE_STRUCT LDKOffersMessage { + LDKOffersMessage_Tag tag; + union { + struct { + struct LDKInvoiceRequest invoice_request; + }; + struct { + struct LDKBolt12Invoice invoice; + }; + struct { + struct LDKInvoiceError invoice_error; + }; + }; +} LDKOffersMessage; /** - * A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not */ -typedef struct LDKCResult_PaymentHashPaymentSendFailureZ { +typedef enum LDKCOption_OffersMessageZ_Tag { /** - * The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage */ - union LDKCResult_PaymentHashPaymentSendFailureZPtr contents; + LDKCOption_OffersMessageZ_Some, /** - * Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. + * When we're in this state, this COption_OffersMessageZ contains nothing */ - bool result_ok; -} LDKCResult_PaymentHashPaymentSendFailureZ; + LDKCOption_OffersMessageZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_OffersMessageZ_Sentinel, +} LDKCOption_OffersMessageZ_Tag; + +typedef struct LDKCOption_OffersMessageZ { + LDKCOption_OffersMessageZ_Tag tag; + union { + struct { + struct LDKOffersMessage some; + }; + }; +} LDKCOption_OffersMessageZ; /** - * The contents of CResult_PaymentHashRetryableSendFailureZ + * The contents of a custom onion message. */ -typedef union LDKCResult_PaymentHashRetryableSendFailureZPtr { +typedef struct LDKCustomOnionMessageContents { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the TLV type identifying the message contents. MUST be >= 64. + */ + uint64_t (*tlv_type)(const void *this_arg); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCustomOnionMessageContents; + +/** + * An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not + */ +typedef enum LDKCOption_CustomOnionMessageContentsZ_Tag { + /** + * When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents + */ + LDKCOption_CustomOnionMessageContentsZ_Some, + /** + * When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing + */ + LDKCOption_CustomOnionMessageContentsZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_CustomOnionMessageContentsZ_Sentinel, +} LDKCOption_CustomOnionMessageContentsZ_Tag; + +typedef struct LDKCOption_CustomOnionMessageContentsZ { + LDKCOption_CustomOnionMessageContentsZ_Tag tag; + union { + struct { + struct LDKCustomOnionMessageContents some; + }; + }; +} LDKCOption_CustomOnionMessageContentsZ; + +/** + * The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ + */ +typedef union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes *result; + struct LDKCOption_CustomOnionMessageContentsZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKRetryableSendFailure *err; -} LDKCResult_PaymentHashRetryableSendFailureZPtr; + struct LDKDecodeError *err; +} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr; /** - * A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. + * A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentHashRetryableSendFailureZ { +typedef struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ { /** - * The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either + * The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentHashRetryableSendFailureZPtr contents; + union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr contents; /** - * Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. + * Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentHashRetryableSendFailureZ; +} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * An enum which can either contain a crate::lightning::ln::wire::Type or not */ -typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { +typedef enum LDKCOption_TypeZ_Tag { /** - * The element at position 0 + * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type */ - struct LDKThirtyTwoBytes a; + LDKCOption_TypeZ_Some, /** - * The element at position 1 + * When we're in this state, this COption_TypeZ contains nothing */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentIdZ; + LDKCOption_TypeZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_TypeZ_Sentinel, +} LDKCOption_TypeZ_Tag; + +typedef struct LDKCOption_TypeZ { + LDKCOption_TypeZ_Tag tag; + union { + struct { + struct LDKType some; + }; + }; +} LDKCOption_TypeZ; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ + * The contents of CResult_COption_TypeZDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { +typedef union LDKCResult_COption_TypeZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_PaymentHashPaymentIdZ *result; + struct LDKCOption_TypeZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; + struct LDKDecodeError *err; +} LDKCResult_COption_TypeZDecodeErrorZPtr; /** - * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. + * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { +typedef struct LDKCResult_COption_TypeZDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either + * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; + union LDKCResult_COption_TypeZDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. + * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; +} LDKCResult_COption_TypeZDecodeErrorZ; /** - * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not */ -typedef struct LDKCVec_ThirtyTwoBytesZ { +typedef enum LDKCOption_NetAddressZ_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress */ - struct LDKThirtyTwoBytes *data; + LDKCOption_NetAddressZ_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_NetAddressZ contains nothing */ - uintptr_t datalen; -} LDKCVec_ThirtyTwoBytesZ; + LDKCOption_NetAddressZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NetAddressZ_Sentinel, +} LDKCOption_NetAddressZ_Tag; + +typedef struct LDKCOption_NetAddressZ { + LDKCOption_NetAddressZ_Tag tag; + union { + struct { + struct LDKNetAddress some; + }; + }; +} LDKCOption_NetAddressZ; /** * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { +typedef struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ { /** * The element at position 0 */ - struct LDKThirtyTwoBytes a; + struct LDKPublicKey a; /** * The element at position 1 */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentSecretZ; + struct LDKCOption_NetAddressZ b; +} LDKC2Tuple_PublicKeyCOption_NetAddressZZ; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +typedef struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_PaymentHashPaymentSecretZ *result; + struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ *data; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * The number of elements pointed to by `data`. */ - void *err; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr; + uintptr_t datalen; +} LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ; + + /** - * A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Error for PeerManager errors. If you get one of these, you must disconnect the socket and + * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the + * descriptor. */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +typedef struct MUST_USE_STRUCT LDKPeerHandleError { /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents; + LDKnativePeerHandleError *inner; /** - * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; + bool is_owned; +} LDKPeerHandleError; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ + * The contents of CResult_CVec_u8ZPeerHandleErrorZ */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { +typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_PaymentHashPaymentSecretZ *result; + struct LDKCVec_u8Z *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKAPIError *err; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; /** - * A CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { +typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either + * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr contents; + union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; /** - * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. + * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; +} LDKCResult_CVec_u8ZPeerHandleErrorZ; /** - * The contents of CResult_PaymentSecretNoneZ + * The contents of CResult_NonePeerHandleErrorZ */ -typedef union LDKCResult_PaymentSecretNoneZPtr { +typedef union LDKCResult_NonePeerHandleErrorZPtr { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKThirtyTwoBytes *result; + void *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_PaymentSecretNoneZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_NonePeerHandleErrorZPtr; /** - * A CResult_PaymentSecretNoneZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. + * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentSecretNoneZ { +typedef struct LDKCResult_NonePeerHandleErrorZ { /** - * The contents of this CResult_PaymentSecretNoneZ, accessible via either + * The contents of this CResult_NonePeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentSecretNoneZPtr contents; + union LDKCResult_NonePeerHandleErrorZPtr contents; /** - * Whether this CResult_PaymentSecretNoneZ represents a success state. + * Whether this CResult_NonePeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentSecretNoneZ; +} LDKCResult_NonePeerHandleErrorZ; /** - * The contents of CResult_PaymentSecretAPIErrorZ + * The contents of CResult_boolPeerHandleErrorZ */ -typedef union LDKCResult_PaymentSecretAPIErrorZPtr { +typedef union LDKCResult_boolPeerHandleErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes *result; + bool *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKAPIError *err; -} LDKCResult_PaymentSecretAPIErrorZPtr; + struct LDKPeerHandleError *err; +} LDKCResult_boolPeerHandleErrorZPtr; /** - * A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, + * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentSecretAPIErrorZ { +typedef struct LDKCResult_boolPeerHandleErrorZ { /** - * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either + * The contents of this CResult_boolPeerHandleErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentSecretAPIErrorZPtr contents; + union LDKCResult_boolPeerHandleErrorZPtr contents; /** - * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + * Whether this CResult_boolPeerHandleErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentSecretAPIErrorZ; +} LDKCResult_boolPeerHandleErrorZ; /** - * The contents of CResult_PaymentPreimageAPIErrorZ + * All-encompassing standard error type that processing can return */ -typedef union LDKCResult_PaymentPreimageAPIErrorZPtr { +typedef enum LDKGraphSyncError_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Error trying to read the update data, typically due to an erroneous data length indication + * that is greater than the actual amount of data provided */ - struct LDKThirtyTwoBytes *result; + LDKGraphSyncError_DecodeError, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Error applying the patch to the network graph, usually the result of updates that are too + * old or missing prerequisite data to the application of updates out of order */ - struct LDKAPIError *err; -} LDKCResult_PaymentPreimageAPIErrorZPtr; + LDKGraphSyncError_LightningError, + /** + * Must be last for serialization purposes + */ + LDKGraphSyncError_Sentinel, +} LDKGraphSyncError_Tag; + +typedef struct MUST_USE_STRUCT LDKGraphSyncError { + LDKGraphSyncError_Tag tag; + union { + struct { + struct LDKDecodeError decode_error; + }; + struct { + struct LDKLightningError lightning_error; + }; + }; +} LDKGraphSyncError; /** - * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * The contents of CResult_u32GraphSyncErrorZ + */ +typedef union LDKCResult_u32GraphSyncErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + uint32_t *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKGraphSyncError *err; +} LDKCResult_u32GraphSyncErrorZPtr; + +/** + * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, + * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentPreimageAPIErrorZ { +typedef struct LDKCResult_u32GraphSyncErrorZ { /** - * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either + * The contents of this CResult_u32GraphSyncErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentPreimageAPIErrorZPtr contents; + union LDKCResult_u32GraphSyncErrorZPtr contents; /** - * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. + * Whether this CResult_u32GraphSyncErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentPreimageAPIErrorZ; - +} LDKCResult_u32GraphSyncErrorZ; +/** + * Represents a valid secp256k1 secret key serialized as a 32 byte array. + */ +typedef struct LDKSecretKey { + /** + * The bytes of the secret key + */ + uint8_t bytes[32]; +} LDKSecretKey; /** - * Information needed for constructing an invoice route hint for this channel. + * An enum which can either contain a crate::c_types::SecretKey or not */ -typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { +typedef enum LDKCOption_KeyPairZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_KeyPairZ contains a crate::c_types::SecretKey */ - LDKnativeCounterpartyForwardingInfo *inner; + LDKCOption_KeyPairZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_KeyPairZ contains nothing */ - bool is_owned; -} LDKCounterpartyForwardingInfo; + LDKCOption_KeyPairZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_KeyPairZ_Sentinel, +} LDKCOption_KeyPairZ_Tag; + +typedef struct LDKCOption_KeyPairZ { + LDKCOption_KeyPairZ_Tag tag; + union { + struct { + struct LDKSecretKey some; + }; + }; +} LDKCOption_KeyPairZ; /** - * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ + * The contents of CResult_COption_KeyPairZNoneZ */ -typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { +typedef union LDKCResult_COption_KeyPairZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCounterpartyForwardingInfo *result; + struct LDKCOption_KeyPairZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; + void *err; +} LDKCResult_COption_KeyPairZNoneZPtr; /** - * A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_KeyPairZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_KeyPairZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { +typedef struct LDKCResult_COption_KeyPairZNoneZ { /** - * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either + * The contents of this CResult_COption_KeyPairZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; + union LDKCResult_COption_KeyPairZNoneZPtr contents; /** - * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + * Whether this CResult_COption_KeyPairZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; +} LDKCResult_COption_KeyPairZNoneZ; +/** + * An enum which can either contain a crate::c_types::derived::CVec_u8Z or not + */ +typedef enum LDKCOption_ScriptZ_Tag { + /** + * When we're in this state, this COption_ScriptZ contains a crate::c_types::derived::CVec_u8Z + */ + LDKCOption_ScriptZ_Some, + /** + * When we're in this state, this COption_ScriptZ contains nothing + */ + LDKCOption_ScriptZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ScriptZ_Sentinel, +} LDKCOption_ScriptZ_Tag; +typedef struct LDKCOption_ScriptZ { + LDKCOption_ScriptZ_Tag tag; + union { + struct { + struct LDKCVec_u8Z some; + }; + }; +} LDKCOption_ScriptZ; /** - * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] - * to better separate parameters. + * A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelCounterparty { +typedef struct LDKCVec_WitnessZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChannelCounterparty *inner; + struct LDKWitness *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChannelCounterparty; + uintptr_t datalen; +} LDKCVec_WitnessZ; /** - * The contents of CResult_ChannelCounterpartyDecodeErrorZ + * An enum which can either contain a i64 or not */ -typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { +typedef enum LDKCOption_i64Z_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * When we're in this state, this COption_i64Z contains a i64 */ - struct LDKChannelCounterparty *result; + LDKCOption_i64Z_Some, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * When we're in this state, this COption_i64Z contains nothing */ - struct LDKDecodeError *err; -} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; + LDKCOption_i64Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_i64Z_Sentinel, +} LDKCOption_i64Z_Tag; + +typedef struct LDKCOption_i64Z { + LDKCOption_i64Z_Tag tag; + union { + struct { + int64_t some; + }; + }; +} LDKCOption_i64Z; /** - * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not */ -typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { +typedef enum LDKCOption_TxidZ_Tag { /** - * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_TxidZ contains a crate::c_types::ThirtyTwoBytes */ - union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; + LDKCOption_TxidZ_Some, /** - * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + * When we're in this state, this COption_TxidZ contains nothing */ - bool result_ok; -} LDKCResult_ChannelCounterpartyDecodeErrorZ; + LDKCOption_TxidZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_TxidZ_Sentinel, +} LDKCOption_TxidZ_Tag; + +typedef struct LDKCOption_TxidZ { + LDKCOption_TxidZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_TxidZ; /** - * The contents of CResult_ChannelDetailsDecodeErrorZ + * The contents of CResult_NetAddressDecodeErrorZ */ -typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { +typedef union LDKCResult_NetAddressDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelDetails *result; + struct LDKNetAddress *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelDetailsDecodeErrorZPtr; +} LDKCResult_NetAddressDecodeErrorZPtr; /** - * A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { +typedef struct LDKCResult_NetAddressDecodeErrorZ { /** - * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either + * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; + union LDKCResult_NetAddressDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. + * Whether this CResult_NetAddressDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelDetailsDecodeErrorZ; +} LDKCResult_NetAddressDecodeErrorZ; /** - * Route hints used in constructing invoices for [phantom node payents]. + * An [`update_add_htlc`] message to be sent to or received from a peer. * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc */ -typedef struct MUST_USE_STRUCT LDKPhantomRouteHints { +typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePhantomRouteHints *inner; + LDKnativeUpdateAddHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPhantomRouteHints; +} LDKUpdateAddHTLC; /** - * The contents of CResult_PhantomRouteHintsDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_PhantomRouteHintsDecodeErrorZPtr { +typedef struct LDKCVec_UpdateAddHTLCZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPhantomRouteHints *result; + struct LDKUpdateAddHTLC *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_PhantomRouteHintsDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_UpdateAddHTLCZ; + + /** - * A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An [`update_fulfill_htlc`] message to be sent to or received from a peer. + * + * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc */ -typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** - * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; + LDKnativeUpdateFulfillHTLC *inner; /** - * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_PhantomRouteHintsDecodeErrorZ; + bool is_owned; +} LDKUpdateFulfillHTLC; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_ChannelMonitorZ { +typedef struct LDKCVec_UpdateFulfillHTLCZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKChannelMonitor *data; + struct LDKUpdateFulfillHTLC *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_ChannelMonitorZ; +} LDKCVec_UpdateFulfillHTLCZ; /** - * An update generated by the underlying channel itself which contains some new information the - * [`ChannelMonitor`] should be made aware of. + * An [`update_fail_htlc`] message to be sent to or received from a peer. * - * Because this represents only a small number of updates to the underlying state, it is generally - * much smaller than a full [`ChannelMonitor`]. However, for large single commitment transaction - * updates (e.g. ones during which there are hundreds of HTLCs pending on the commitment - * transaction), a single update may reach upwards of 1 MiB in serialized size. + * [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc */ -typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { +typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelMonitorUpdate *inner; + LDKnativeUpdateFailHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelMonitorUpdate; +} LDKUpdateFailHTLC; /** - * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as - * blocks are connected and disconnected. - * - * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are - * responsible for maintaining a set of monitors such that they can be updated accordingly as - * channel state changes and HTLCs are resolved. See method documentation for specific - * requirements. - * - * Implementations **must** ensure that updates are successfully applied and persisted upon method - * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down - * without taking any further action such as persisting the current state. - * - * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing - * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it - * could result in a revoked transaction being broadcast, allowing the counterparty to claim all - * funds in the channel. See [`ChannelMonitorUpdateStatus`] for more details about how to handle - * multiple instances. - * - * [`PermanentFailure`]: ChannelMonitorUpdateStatus::PermanentFailure + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKWatch { +typedef struct LDKCVec_UpdateFailHTLCZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void *this_arg; + struct LDKUpdateFailHTLC *data; /** - * Watches a channel identified by `funding_txo` using `monitor`. - * - * Implementations are responsible for watching the chain for the funding transaction along - * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - * calling [`block_connected`] and [`block_disconnected`] on the monitor. - * - * Note: this interface MUST error with [`ChannelMonitorUpdateStatus::PermanentFailure`] if - * the given `funding_txo` has previously been registered via `watch_channel`. - * - * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + * The number of elements pointed to by `data`. */ - enum LDKChannelMonitorUpdateStatus (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + uintptr_t datalen; +} LDKCVec_UpdateFailHTLCZ; + + + +/** + * An [`update_fail_malformed_htlc`] message to be sent to or received from a peer. + * + * [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc + */ +typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { /** - * Updates a channel identified by `funding_txo` by applying `update` to its monitor. - * - * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. - * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - enum LDKChannelMonitorUpdateStatus (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update); + LDKnativeUpdateFailMalformedHTLC *inner; /** - * 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::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ (*release_pending_monitor_events)(const void *this_arg); + bool is_owned; +} LDKUpdateFailMalformedHTLC; + +/** + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_UpdateFailMalformedHTLCZ { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*free)(void *this_arg); -} LDKWatch; + struct LDKUpdateFailMalformedHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_UpdateFailMalformedHTLCZ; /** - * An interface to send a transaction to the Bitcoin network. + * The contents of CResult_AcceptChannelDecodeErrorZ */ -typedef struct LDKBroadcasterInterface { +typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKAcceptChannel *result; /** - * Sends a transaction out to (hopefully) be mined. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + struct LDKDecodeError *err; +} LDKCResult_AcceptChannelDecodeErrorZPtr; + +/** + * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_AcceptChannelDecodeErrorZ { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*free)(void *this_arg); -} LDKBroadcasterInterface; + union LDKCResult_AcceptChannelDecodeErrorZPtr contents; + /** + * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_AcceptChannelDecodeErrorZ; /** - * A trait that describes a source of entropy. + * The contents of CResult_AcceptChannelV2DecodeErrorZ */ -typedef struct LDKEntropySource { +typedef union LDKCResult_AcceptChannelV2DecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKAcceptChannelV2 *result; /** - * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a - * different value each time it is called. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + struct LDKDecodeError *err; +} LDKCResult_AcceptChannelV2DecodeErrorZPtr; + +/** + * A CResult_AcceptChannelV2DecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_AcceptChannelV2DecodeErrorZ { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The contents of this CResult_AcceptChannelV2DecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*free)(void *this_arg); -} LDKEntropySource; + union LDKCResult_AcceptChannelV2DecodeErrorZPtr contents; + /** + * Whether this CResult_AcceptChannelV2DecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_AcceptChannelV2DecodeErrorZ; /** - * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not - * own the memory pointed to by data. + * The contents of CResult_TxAddInputDecodeErrorZ */ -typedef struct LDKu8slice { +typedef union LDKCResult_TxAddInputDecodeErrorZPtr { /** - * A pointer to the byte buffer + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - const uint8_t *data; + struct LDKTxAddInput *result; /** - * The number of bytes pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKu8slice; - - + struct LDKDecodeError *err; +} LDKCResult_TxAddInputDecodeErrorZPtr; /** - * The unsigned part of a [`channel_update`] message. - * - * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * A CResult_TxAddInputDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxAddInput on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate { +typedef struct LDKCResult_TxAddInputDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_TxAddInputDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUnsignedChannelUpdate *inner; + union LDKCResult_TxAddInputDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_TxAddInputDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKUnsignedChannelUpdate; - - + bool result_ok; +} LDKCResult_TxAddInputDecodeErrorZ; /** - * The unsigned part of a [`node_announcement`] message. - * - * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message + * The contents of CResult_TxAddOutputDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement { +typedef union LDKCResult_TxAddOutputDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeUnsignedNodeAnnouncement *inner; + struct LDKTxAddOutput *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKUnsignedNodeAnnouncement; + struct LDKDecodeError *err; +} LDKCResult_TxAddOutputDecodeErrorZPtr; /** - * Represents the set of gossip messages that require a signature from a node's identity key. + * A CResult_TxAddOutputDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxAddOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKUnsignedGossipMessage_Tag { +typedef struct LDKCResult_TxAddOutputDecodeErrorZ { /** - * An unsigned channel announcement. + * The contents of this CResult_TxAddOutputDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKUnsignedGossipMessage_ChannelAnnouncement, + union LDKCResult_TxAddOutputDecodeErrorZPtr contents; /** - * An unsigned channel update. + * Whether this CResult_TxAddOutputDecodeErrorZ represents a success state. */ - LDKUnsignedGossipMessage_ChannelUpdate, + bool result_ok; +} LDKCResult_TxAddOutputDecodeErrorZ; + +/** + * The contents of CResult_TxRemoveInputDecodeErrorZ + */ +typedef union LDKCResult_TxRemoveInputDecodeErrorZPtr { /** - * An unsigned node announcement. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKUnsignedGossipMessage_NodeAnnouncement, + struct LDKTxRemoveInput *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKUnsignedGossipMessage_Sentinel, -} LDKUnsignedGossipMessage_Tag; - -typedef struct MUST_USE_STRUCT LDKUnsignedGossipMessage { - LDKUnsignedGossipMessage_Tag tag; - union { - struct { - struct LDKUnsignedChannelAnnouncement channel_announcement; - }; - struct { - struct LDKUnsignedChannelUpdate channel_update; - }; - struct { - struct LDKUnsignedNodeAnnouncement node_announcement; - }; - }; -} LDKUnsignedGossipMessage; + struct LDKDecodeError *err; +} LDKCResult_TxRemoveInputDecodeErrorZPtr; /** - * A trait that can handle cryptographic operations at the scope level of a node. + * A CResult_TxRemoveInputDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxRemoveInput on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKNodeSigner { +typedef struct LDKCResult_TxRemoveInputDecodeErrorZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The contents of this CResult_TxRemoveInputDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void *this_arg; + union LDKCResult_TxRemoveInputDecodeErrorZPtr contents; /** - * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. - * - * If the implementor of this trait supports [phantom node payments], then every node that is - * intended to be included in the phantom invoice route hints must return the same value from - * this method. - * - * This method must return the same value each time it is called. - * - * [phantom node payments]: PhantomKeysManager - */ - struct LDKThirtyTwoBytes (*get_inbound_payment_key_material)(const void *this_arg); - /** - * Get node id based on the provided [`Recipient`]. - * - * This method must return the same value each time it is called with a given [`Recipient`] - * parameter. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. - */ - struct LDKCResult_PublicKeyNoneZ (*get_node_id)(const void *this_arg, enum LDKRecipient recipient); - /** - * Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if - * one is provided. Note that this tweak can be applied to `other_key` instead of our node - * secret, though this is less efficient. - * - * Note that if this fails while attempting to forward an HTLC, LDK will panic. The error - * should be resolved to allow LDK to resume forwarding HTLCs. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. - */ - struct LDKCResult_SharedSecretNoneZ (*ecdh)(const void *this_arg, enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak); - /** - * Sign an invoice. - * - * By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of - * this trait to parse the invoice and make sure they're signing what they expect, rather than - * blindly signing the hash. - * - * The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. - * - * The secret key used to sign the invoice is dependent on the [`Recipient`]. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. - */ - struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); - /** - * Sign a gossip message. - * - * Note that if this fails, LDK may panic and the message will not be broadcast to the network - * or a possible channel counterparty. If LDK panics, the error should be resolved to allow the - * message to be broadcast, as otherwise it may prevent one from receiving funds over the - * corresponding channel. - */ - struct LDKCResult_SignatureNoneZ (*sign_gossip_message)(const void *this_arg, struct LDKUnsignedGossipMessage msg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_TxRemoveInputDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKNodeSigner; + bool result_ok; +} LDKCResult_TxRemoveInputDecodeErrorZ; /** - * A trait that can return signer instances for individual channels. + * The contents of CResult_TxRemoveOutputDecodeErrorZ */ -typedef struct LDKSignerProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_TxRemoveOutputDecodeErrorZPtr { /** - * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through - * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow - * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated - * `channel_keys_id`. - * - * This method must return a different value each time it is called. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes (*generate_channel_keys_id)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis, struct LDKU128 user_channel_id); + struct LDKTxRemoveOutput *result; /** - * Derives the private key material backing a `Signer`. - * - * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through - * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be - * re-derived from its `channel_keys_id`, which can be obtained through its trait method - * [`ChannelSigner::channel_keys_id`]. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKWriteableEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); + struct LDKDecodeError *err; +} LDKCResult_TxRemoveOutputDecodeErrorZPtr; + +/** + * A CResult_TxRemoveOutputDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxRemoveOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TxRemoveOutputDecodeErrorZ { /** - * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. - * This is only called during deserialization of other objects which contain - * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). - * The bytes are exactly those which `::write()` writes, and - * contain no versioning scheme. You may wish to include your own version prefix and ensure - * you've read all of the provided bytes to ensure no corruption occurred. - * - * This method is slowly being phased out -- it will only be called when reading objects - * written by LDK versions prior to 0.0.113. - * - * [`Signer`]: Self::Signer - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * The contents of this CResult_TxRemoveOutputDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + union LDKCResult_TxRemoveOutputDecodeErrorZPtr contents; /** - * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. + * Whether this CResult_TxRemoveOutputDecodeErrorZ represents a success state. */ - struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); + bool result_ok; +} LDKCResult_TxRemoveOutputDecodeErrorZ; + +/** + * The contents of CResult_TxCompleteDecodeErrorZ + */ +typedef union LDKCResult_TxCompleteDecodeErrorZPtr { /** - * Get a script pubkey which we will send funds to when closing a channel. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg); + struct LDKTxComplete *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKSignerProvider; + struct LDKDecodeError *err; +} LDKCResult_TxCompleteDecodeErrorZPtr; /** - * A trait which should be implemented to provide feerate information on a number of time - * horizons. - * - * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're - * called from inside the library in response to chain events, P2P events, or timer events). + * A CResult_TxCompleteDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxComplete on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKFeeEstimator { +typedef struct LDKCResult_TxCompleteDecodeErrorZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Gets estimated satoshis of fee required per 1000 Weight-Units. - * - * LDK will wrap this method and ensure that the value returned is no smaller than 253 - * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte). - * - * The following unit conversions can be used to convert to sats/KW: - * * satoshis-per-byte * 250 - * * satoshis-per-kbyte / 4 + * The contents of this CResult_TxCompleteDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + union LDKCResult_TxCompleteDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_TxCompleteDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKFeeEstimator; + bool result_ok; +} LDKCResult_TxCompleteDecodeErrorZ; /** - * A trait defining behavior for routing a payment. + * The contents of CResult_TxSignaturesDecodeErrorZ */ -typedef struct LDKRouter { +typedef union LDKCResult_TxSignaturesDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKTxSignatures *result; /** - * 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 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); + struct LDKDecodeError *err; +} LDKCResult_TxSignaturesDecodeErrorZPtr; + +/** + * A CResult_TxSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TxSignaturesDecodeErrorZ { /** - * Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes - * `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment. - * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_TxSignaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_RouteLightningErrorZ (*find_route_with_id)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); + union LDKCResult_TxSignaturesDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_TxSignaturesDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKRouter; - - + bool result_ok; +} LDKCResult_TxSignaturesDecodeErrorZ; /** - * Manager which keeps track of a number of channels and sends messages to the appropriate - * channel, also tracking HTLC preimages and forwarding onion packets appropriately. - * - * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through - * to individual Channels. - * - * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for - * all peers during write/read (though does not modify this instance, only the instance being - * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e., - * called [`funding_transaction_generated`] for outbound channels) being closed. - * - * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with - * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST write each monitor update out to disk before - * returning from [`chain::Watch::watch_channel`]/[`update_channel`], with ChannelManagers, writing updates - * happens out-of-band (and will prevent any other `ChannelManager` operations from occurring during - * the serialization process). If the deserialized version is out-of-date compared to the - * [`ChannelMonitor`] passed by reference to [`read`], those channels will be force-closed based on the - * `ChannelMonitor` state and no funds will be lost (mod on-chain transaction fees). - * - * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which - * tells you the last block hash which was connected. You should get the best block tip before using the manager. - * See [`chain::Listen`] and [`chain::Confirm`] for more details. - * - * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating - * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid - * spam due to quick disconnection/reconnection, updates are not sent until the channel has been - * offline for a full minute. In order to track this, you must call - * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect. - * - * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and - * inbound channels without confirmed funding transactions. This may result in nodes which we do - * not have a channel with being unable to connect to us or open new channels with us if we have - * many peers with unfunded channels. - * - * Because it is an indication of trust, inbound channels which we've accepted as 0conf are - * exempted from the count of unfunded channels. Similarly, outbound channels and connections are - * never limited. Please ensure you limit the count of such channels yourself. - * - * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`] - * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but - * essentially you should default to using a [`SimpleRefChannelManager`], and use a - * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when - * you're using lightning-net-tokio. - * - * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected - * [`funding_created`]: msgs::FundingCreated - * [`funding_transaction_generated`]: Self::funding_transaction_generated - * [`BlockHash`]: bitcoin::hash_types::BlockHash - * [`update_channel`]: chain::Watch::update_channel - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`timer_tick_occurred`]: Self::timer_tick_occurred - * [`read`]: ReadableArgs::read + * The contents of CResult_TxInitRbfDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelManager { +typedef union LDKCResult_TxInitRbfDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelManager *inner; + struct LDKTxInitRbf *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelManager; + struct LDKDecodeError *err; +} LDKCResult_TxInitRbfDecodeErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_TxInitRbfDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxInitRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_BlockHashChannelManagerZ { +typedef struct LDKCResult_TxInitRbfDecodeErrorZ { /** - * The element at position 0 + * The contents of this CResult_TxInitRbfDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes a; + union LDKCResult_TxInitRbfDecodeErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_TxInitRbfDecodeErrorZ represents a success state. */ - struct LDKChannelManager b; -} LDKC2Tuple_BlockHashChannelManagerZ; + bool result_ok; +} LDKCResult_TxInitRbfDecodeErrorZ; /** - * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + * The contents of CResult_TxAckRbfDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { +typedef union LDKCResult_TxAckRbfDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelManagerZ *result; + struct LDKTxAckRbf *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; +} LDKCResult_TxAckRbfDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_TxAckRbfDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxAckRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +typedef struct LDKCResult_TxAckRbfDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * The contents of this CResult_TxAckRbfDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + union LDKCResult_TxAckRbfDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + * Whether this CResult_TxAckRbfDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; +} LDKCResult_TxAckRbfDecodeErrorZ; /** - * Options which apply on a per-channel basis and may change at runtime or based on negotiation - * with our counterparty. + * A tx_abort message which signals the cancellation of an in-progress transaction negotiation. + * */ -typedef struct MUST_USE_STRUCT LDKChannelConfig { +typedef struct MUST_USE_STRUCT LDKTxAbort { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelConfig *inner; + LDKnativeTxAbort *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelConfig; +} LDKTxAbort; /** - * The contents of CResult_ChannelConfigDecodeErrorZ + * The contents of CResult_TxAbortDecodeErrorZ */ -typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { +typedef union LDKCResult_TxAbortDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelConfig *result; + struct LDKTxAbort *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelConfigDecodeErrorZPtr; +} LDKCResult_TxAbortDecodeErrorZPtr; /** - * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_TxAbortDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::TxAbort on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelConfigDecodeErrorZ { +typedef struct LDKCResult_TxAbortDecodeErrorZ { /** - * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + * The contents of this CResult_TxAbortDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelConfigDecodeErrorZPtr contents; + union LDKCResult_TxAbortDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + * Whether this CResult_TxAbortDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelConfigDecodeErrorZ; +} LDKCResult_TxAbortDecodeErrorZ; /** - * An enum which can either contain a crate::lightning::util::errors::APIError or not + * The contents of CResult_AnnouncementSignaturesDecodeErrorZ */ -typedef enum LDKCOption_APIErrorZ_Tag { +typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { /** - * When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_APIErrorZ_Some, + struct LDKAnnouncementSignatures *result; /** - * When we're in this state, this COption_APIErrorZ contains nothing + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_APIErrorZ_None, + struct LDKDecodeError *err; +} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; + +/** + * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_APIErrorZ_Sentinel, -} LDKCOption_APIErrorZ_Tag; - -typedef struct LDKCOption_APIErrorZ { - LDKCOption_APIErrorZ_Tag tag; - union { - struct { - struct LDKAPIError some; - }; - }; -} LDKCOption_APIErrorZ; + union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; + /** + * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_AnnouncementSignaturesDecodeErrorZ; /** - * The contents of CResult_COption_APIErrorZDecodeErrorZ + * The contents of CResult_ChannelReestablishDecodeErrorZ */ -typedef union LDKCResult_COption_APIErrorZDecodeErrorZPtr { +typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_APIErrorZ *result; + struct LDKChannelReestablish *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_APIErrorZDecodeErrorZPtr; +} LDKCResult_ChannelReestablishDecodeErrorZPtr; /** - * A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_APIErrorZDecodeErrorZ { +typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { /** - * The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_APIErrorZDecodeErrorZPtr contents; + union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; /** - * Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. + * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_APIErrorZDecodeErrorZ; +} LDKCResult_ChannelReestablishDecodeErrorZ; /** - * The contents of CResult_UntrustedStringDecodeErrorZ + * The contents of CResult_ClosingSignedDecodeErrorZ */ -typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { +typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUntrustedString *result; + struct LDKClosingSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UntrustedStringDecodeErrorZPtr; +} LDKCResult_ClosingSignedDecodeErrorZPtr; /** - * A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UntrustedStringDecodeErrorZ { +typedef struct LDKCResult_ClosingSignedDecodeErrorZ { /** - * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UntrustedStringDecodeErrorZPtr contents; + union LDKCResult_ClosingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UntrustedStringDecodeErrorZ; +} LDKCResult_ClosingSignedDecodeErrorZ; + + /** - * The contents of CResult_OutPointDecodeErrorZ + * The minimum and maximum fees which the sender is willing to place on the closing transaction. + * + * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing + * to use. */ -typedef union LDKCResult_OutPointDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeClosingSignedFeeRange *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKClosingSignedFeeRange; + +/** + * The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ + */ +typedef union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint *result; + struct LDKClosingSignedFeeRange *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_OutPointDecodeErrorZPtr; +} LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr; /** - * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_OutPointDecodeErrorZ { +typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { /** - * The contents of this CResult_OutPointDecodeErrorZ, accessible via either + * The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OutPointDecodeErrorZPtr contents; + union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr contents; /** - * Whether this CResult_OutPointDecodeErrorZ represents a success state. + * Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OutPointDecodeErrorZ; +} LDKCResult_ClosingSignedFeeRangeDecodeErrorZ; + + /** - * Defines a type identifier for sending messages over the wire. + * A [`commitment_signed`] message to be sent to or received from a peer. * - * Messages implementing this trait specify a type and must be [`Writeable`]. + * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed */ -typedef struct LDKType { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct MUST_USE_STRUCT LDKCommitmentSigned { /** - * Returns the type identifying the message payload. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - uint16_t (*type_id)(const void *this_arg); + LDKnativeCommitmentSigned *inner; /** - * Return a human-readable "debug" string describing this object + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKStr (*debug_str)(const void *this_arg); + bool is_owned; +} LDKCommitmentSigned; + +/** + * The contents of CResult_CommitmentSignedDecodeErrorZ + */ +typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { /** - * Serialize the object into a byte array + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + struct LDKCommitmentSigned *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKType; + struct LDKDecodeError *err; +} LDKCResult_CommitmentSignedDecodeErrorZPtr; /** - * An enum which can either contain a crate::lightning::ln::wire::Type or not + * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKCOption_TypeZ_Tag { - /** - * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type - */ - LDKCOption_TypeZ_Some, +typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { /** - * When we're in this state, this COption_TypeZ contains nothing + * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_TypeZ_None, + union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. */ - LDKCOption_TypeZ_Sentinel, -} LDKCOption_TypeZ_Tag; - -typedef struct LDKCOption_TypeZ { - LDKCOption_TypeZ_Tag tag; - union { - struct { - struct LDKType some; - }; - }; -} LDKCOption_TypeZ; + bool result_ok; +} LDKCResult_CommitmentSignedDecodeErrorZ; /** - * The contents of CResult_COption_TypeZDecodeErrorZ + * The contents of CResult_FundingCreatedDecodeErrorZ */ -typedef union LDKCResult_COption_TypeZDecodeErrorZPtr { +typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_TypeZ *result; + struct LDKFundingCreated *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_TypeZDecodeErrorZPtr; +} LDKCResult_FundingCreatedDecodeErrorZPtr; /** - * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_TypeZDecodeErrorZ { +typedef struct LDKCResult_FundingCreatedDecodeErrorZ { /** - * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either + * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_TypeZDecodeErrorZPtr contents; + union LDKCResult_FundingCreatedDecodeErrorZPtr contents; /** - * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. + * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_TypeZDecodeErrorZ; +} LDKCResult_FundingCreatedDecodeErrorZ; /** - * An error that may occur when making a payment. + * The contents of CResult_FundingSignedDecodeErrorZ */ -typedef enum LDKPaymentError_Tag { +typedef union LDKCResult_FundingSignedDecodeErrorZPtr { /** - * An error resulting from the provided [`Invoice`] or payment hash. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentError_Invoice, + struct LDKFundingSigned *result; /** - * An error occurring when sending a payment. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKPaymentError_Sending, + struct LDKDecodeError *err; +} LDKCResult_FundingSignedDecodeErrorZPtr; + +/** + * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_FundingSignedDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKPaymentError_Sentinel, -} LDKPaymentError_Tag; - -typedef struct MUST_USE_STRUCT LDKPaymentError { - LDKPaymentError_Tag tag; - union { - struct { - struct LDKStr invoice; - }; - struct { - enum LDKRetryableSendFailure sending; - }; - }; -} LDKPaymentError; + union LDKCResult_FundingSignedDecodeErrorZPtr contents; + /** + * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FundingSignedDecodeErrorZ; /** - * The contents of CResult_PaymentIdPaymentErrorZ + * The contents of CResult_ChannelReadyDecodeErrorZ */ -typedef union LDKCResult_PaymentIdPaymentErrorZPtr { +typedef union LDKCResult_ChannelReadyDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes *result; + struct LDKChannelReady *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentError *err; -} LDKCResult_PaymentIdPaymentErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelReadyDecodeErrorZPtr; /** - * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. + * A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentIdPaymentErrorZ { +typedef struct LDKCResult_ChannelReadyDecodeErrorZ { /** - * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either + * The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentIdPaymentErrorZPtr contents; + union LDKCResult_ChannelReadyDecodeErrorZPtr contents; /** - * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. + * Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentIdPaymentErrorZ; +} LDKCResult_ChannelReadyDecodeErrorZ; + + /** - * The contents of CResult_NonePaymentErrorZ + * An [`init`] message to be sent to or received from a peer. + * + * [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message */ -typedef union LDKCResult_NonePaymentErrorZPtr { +typedef struct MUST_USE_STRUCT LDKInit { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *result; + LDKnativeInit *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInit; + +/** + * The contents of CResult_InitDecodeErrorZ + */ +typedef union LDKCResult_InitDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInit *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentError *err; -} LDKCResult_NonePaymentErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_InitDecodeErrorZPtr; /** - * A CResult_NonePaymentErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. + * A CResult_InitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NonePaymentErrorZ { +typedef struct LDKCResult_InitDecodeErrorZ { /** - * The contents of this CResult_NonePaymentErrorZ, accessible via either + * The contents of this CResult_InitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePaymentErrorZPtr contents; + union LDKCResult_InitDecodeErrorZPtr contents; /** - * Whether this CResult_NonePaymentErrorZ represents a success state. + * Whether this CResult_InitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NonePaymentErrorZ; +} LDKCResult_InitDecodeErrorZ; /** - * The contents of CResult_StringErrorZ + * The contents of CResult_OpenChannelDecodeErrorZ */ -typedef union LDKCResult_StringErrorZPtr { +typedef union LDKCResult_OpenChannelDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKStr *result; + struct LDKOpenChannel *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSecp256k1Error *err; -} LDKCResult_StringErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_OpenChannelDecodeErrorZPtr; /** - * A CResult_StringErrorZ represents the result of a fallible operation, - * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_StringErrorZ { +typedef struct LDKCResult_OpenChannelDecodeErrorZ { /** - * The contents of this CResult_StringErrorZ, accessible via either + * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_StringErrorZPtr contents; + union LDKCResult_OpenChannelDecodeErrorZPtr contents; /** - * Whether this CResult_StringErrorZ represents a success state. + * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_StringErrorZ; +} LDKCResult_OpenChannelDecodeErrorZ; /** - * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + * The contents of CResult_OpenChannelV2DecodeErrorZ */ -typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { +typedef union LDKCResult_OpenChannelV2DecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelMonitorUpdate *result; + struct LDKOpenChannelV2 *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; +} LDKCResult_OpenChannelV2DecodeErrorZPtr; /** - * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OpenChannelV2DecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OpenChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { +typedef struct LDKCResult_OpenChannelV2DecodeErrorZ { /** - * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_OpenChannelV2DecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; + union LDKCResult_OpenChannelV2DecodeErrorZPtr contents; /** - * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + * Whether this CResult_OpenChannelV2DecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; +} LDKCResult_OpenChannelV2DecodeErrorZ; /** - * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not + * The contents of CResult_RevokeAndACKDecodeErrorZ */ -typedef enum LDKCOption_MonitorEventZ_Tag { +typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { /** - * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_MonitorEventZ_Some, + struct LDKRevokeAndACK *result; /** - * When we're in this state, this COption_MonitorEventZ contains nothing + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_MonitorEventZ_None, + struct LDKDecodeError *err; +} LDKCResult_RevokeAndACKDecodeErrorZPtr; + +/** + * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_MonitorEventZ_Sentinel, -} LDKCOption_MonitorEventZ_Tag; - -typedef struct LDKCOption_MonitorEventZ { - LDKCOption_MonitorEventZ_Tag tag; - union { - struct { - struct LDKMonitorEvent some; - }; - }; -} LDKCOption_MonitorEventZ; + union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; + /** + * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RevokeAndACKDecodeErrorZ; /** - * The contents of CResult_COption_MonitorEventZDecodeErrorZ + * The contents of CResult_ShutdownDecodeErrorZ */ -typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr { +typedef union LDKCResult_ShutdownDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_MonitorEventZ *result; + struct LDKShutdown *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_MonitorEventZDecodeErrorZPtr; +} LDKCResult_ShutdownDecodeErrorZPtr; /** - * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_MonitorEventZDecodeErrorZ { +typedef struct LDKCResult_ShutdownDecodeErrorZ { /** - * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either + * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents; + union LDKCResult_ShutdownDecodeErrorZPtr contents; /** - * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + * Whether this CResult_ShutdownDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_MonitorEventZDecodeErrorZ; +} LDKCResult_ShutdownDecodeErrorZ; /** - * The contents of CResult_HTLCUpdateDecodeErrorZ + * The contents of CResult_UpdateFailHTLCDecodeErrorZ */ -typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { +typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKHTLCUpdate *result; + struct LDKUpdateFailHTLC *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_HTLCUpdateDecodeErrorZPtr; +} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; /** - * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { +typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { /** - * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; + union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; /** - * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_HTLCUpdateDecodeErrorZ; +} LDKCResult_UpdateFailHTLCDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ */ -typedef struct LDKC2Tuple_OutPointScriptZ { +typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint a; + struct LDKUpdateFailMalformedHTLC *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_OutPointScriptZ; + struct LDKDecodeError *err; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_u32ScriptZ { +typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { /** - * The element at position 0 + * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint32_t a; + union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_u32ScriptZ; + bool result_ok; +} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. - * This corresponds to std::vector in C++ + * An [`update_fee`] message to be sent to or received from a peer + * + * [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee */ -typedef struct LDKCVec_C2Tuple_u32ScriptZZ { +typedef struct MUST_USE_STRUCT LDKUpdateFee { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_u32ScriptZ *data; + LDKnativeUpdateFee *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32ScriptZZ; + bool is_owned; +} LDKUpdateFee; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_UpdateFeeDecodeErrorZ */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { +typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes a; + struct LDKUpdateFee *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_C2Tuple_u32ScriptZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + struct LDKDecodeError *err; +} LDKCResult_UpdateFeeDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +typedef struct LDKCResult_UpdateFeeDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + union LDKCResult_UpdateFeeDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; + bool result_ok; +} LDKCResult_UpdateFeeDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::events::Events of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ */ -typedef struct LDKCVec_EventZ { +typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKEvent *data; + struct LDKUpdateFulfillHTLC *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_EventZ; + struct LDKDecodeError *err; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_TransactionZ { +typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKTransaction *data; + union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_TransactionZ; + bool result_ok; +} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_UpdateAddHTLCDecodeErrorZ */ -typedef struct LDKC2Tuple_u32TxOutZ { +typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint32_t a; + struct LDKUpdateAddHTLC *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKTxOut b; -} LDKC2Tuple_u32TxOutZ; + struct LDKDecodeError *err; +} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_u32TxOutZZ { +typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_u32TxOutZ *data; + union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32TxOutZZ; + bool result_ok; +} LDKCResult_UpdateAddHTLCDecodeErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * An onion message to be sent to or received from a peer. + * */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { +typedef struct MUST_USE_STRUCT LDKOnionMessage { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes a; + LDKnativeOnionMessage *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_C2Tuple_u32TxOutZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; + bool is_owned; +} LDKOnionMessage; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_OnionMessageDecodeErrorZ */ -typedef struct LDKCVec_TransactionOutputsZ { +typedef union LDKCResult_OnionMessageDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *data; + struct LDKOnionMessage *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_TransactionOutputsZ; + struct LDKDecodeError *err; +} LDKCResult_OnionMessageDecodeErrorZPtr; /** - * Details about the balance(s) available for spending once the channel appears on chain. - * - * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not - * be provided. + * A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKBalance_Tag { - /** - * The channel is not yet closed (or the commitment or closing transaction has not yet - * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is - * force-closed now. - */ - LDKBalance_ClaimableOnChannelClose, +typedef struct LDKCResult_OnionMessageDecodeErrorZ { /** - * The channel has been closed, and the given balance is ours but awaiting confirmations until - * we consider it spendable. + * The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKBalance_ClaimableAwaitingConfirmations, + union LDKCResult_OnionMessageDecodeErrorZPtr contents; /** - * The channel has been closed, and the given balance should be ours but awaiting spending - * transaction confirmation. If the spending transaction does not confirm in time, it is - * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain. - * - * Once the spending transaction confirms, before it has reached enough confirmations to be - * considered safe from chain reorganizations, the balance will instead be provided via - * [`Balance::ClaimableAwaitingConfirmations`]. + * Whether this CResult_OnionMessageDecodeErrorZ represents a success state. */ - LDKBalance_ContentiousClaimable, + bool result_ok; +} LDKCResult_OnionMessageDecodeErrorZ; + + + +/** + * A [`ping`] message to be sent to or received from a peer. + * + * [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages + */ +typedef struct MUST_USE_STRUCT LDKPing { /** - * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain - * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat - * likely to be claimed by our counterparty before we do. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKBalance_MaybeTimeoutClaimableHTLC, + LDKnativePing *inner; /** - * HTLCs which we received from our counterparty which are claimable with a preimage which we - * do not currently have. This will only be claimable if we receive the preimage from the node - * to which we forwarded this HTLC before the timeout. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKBalance_MaybePreimageClaimableHTLC, + bool is_owned; +} LDKPing; + +/** + * The contents of CResult_PingDecodeErrorZ + */ +typedef union LDKCResult_PingDecodeErrorZPtr { /** - * The channel has been closed, and our counterparty broadcasted a revoked commitment - * transaction. - * - * Thus, we're able to claim all outputs in the commitment transaction, one of which has the - * following amount. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKBalance_CounterpartyRevokedOutputClaimable, + struct LDKPing *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKBalance_Sentinel, -} LDKBalance_Tag; + struct LDKDecodeError *err; +} LDKCResult_PingDecodeErrorZPtr; -typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { - /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. +/** + * A CResult_PingDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PingDecodeErrorZ { + /** + * The contents of this CResult_PingDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint64_t claimable_amount_satoshis; -} LDKBalance_LDKClaimableOnChannelClose_Body; + union LDKCResult_PingDecodeErrorZPtr contents; + /** + * Whether this CResult_PingDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PingDecodeErrorZ; -typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { + + +/** + * A [`pong`] message to be sent to or received from a peer. + * + * [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages + */ +typedef struct MUST_USE_STRUCT LDKPong { /** - * The amount available to claim, in satoshis, possibly excluding the on-chain fees which - * were spent in broadcasting the transaction. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - uint64_t claimable_amount_satoshis; + LDKnativePong *inner; /** - * The height at which an [`Event::SpendableOutputs`] event will be generated for this - * amount. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uint32_t confirmation_height; -} LDKBalance_LDKClaimableAwaitingConfirmations_Body; + bool is_owned; +} LDKPong; -typedef struct LDKBalance_LDKContentiousClaimable_Body { +/** + * The contents of CResult_PongDecodeErrorZ + */ +typedef union LDKCResult_PongDecodeErrorZPtr { /** - * The amount available to claim, in satoshis, excluding the on-chain fees which will be - * required to do so. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint64_t claimable_amount_satoshis; + struct LDKPong *result; /** - * The height at which the counterparty may be able to claim the balance if we have not - * done so. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint32_t timeout_height; -} LDKBalance_LDKContentiousClaimable_Body; + struct LDKDecodeError *err; +} LDKCResult_PongDecodeErrorZPtr; -typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { +/** + * A CResult_PongDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PongDecodeErrorZ { /** - * The amount potentially available to claim, in satoshis, excluding the on-chain fees - * which will be required to do so. + * The contents of this CResult_PongDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint64_t claimable_amount_satoshis; + union LDKCResult_PongDecodeErrorZPtr contents; /** - * The height at which we will be able to claim the balance if our counterparty has not - * done so. + * Whether this CResult_PongDecodeErrorZ represents a success state. */ - uint32_t claimable_height; -} LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; + bool result_ok; +} LDKCResult_PongDecodeErrorZ; -typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { +/** + * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ + */ +typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /** - * The amount potentially available to claim, in satoshis, excluding the on-chain fees - * which will be required to do so. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint64_t claimable_amount_satoshis; + struct LDKUnsignedChannelAnnouncement *result; /** - * The height at which our counterparty will be able to claim the balance if we have not - * yet received the preimage and claimed it ourselves. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint32_t expiry_height; -} LDKBalance_LDKMaybePreimageClaimableHTLC_Body; + struct LDKDecodeError *err; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; -typedef struct LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body { +/** + * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { /** - * The amount, in satoshis, of the output which we can claim. - * - * Note that for outputs from HTLC balances this may be excluding some on-chain fees that - * were already spent. + * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint64_t claimable_amount_satoshis; -} LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body; + union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; + /** + * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; -typedef struct MUST_USE_STRUCT LDKBalance { - LDKBalance_Tag tag; - union { - LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close; - LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations; - LDKBalance_LDKContentiousClaimable_Body contentious_claimable; - LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body maybe_timeout_claimable_htlc; - LDKBalance_LDKMaybePreimageClaimableHTLC_Body maybe_preimage_claimable_htlc; - LDKBalance_LDKCounterpartyRevokedOutputClaimable_Body counterparty_revoked_output_claimable; - }; -} LDKBalance; +/** + * The contents of CResult_ChannelAnnouncementDecodeErrorZ + */ +typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelAnnouncement *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_BalanceZ { +typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKBalance *data; + union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_BalanceZ; + bool result_ok; +} LDKCResult_ChannelAnnouncementDecodeErrorZ; /** - * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ + * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *result; + struct LDKUnsignedChannelUpdate *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr contents; + union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; +} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_ChannelUpdateDecodeErrorZ */ -typedef struct LDKC2Tuple_PublicKeyTypeZ { +typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey a; + struct LDKChannelUpdate *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKType b; -} LDKC2Tuple_PublicKeyTypeZ; + struct LDKDecodeError *err; +} LDKCResult_ChannelUpdateDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { +typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_PublicKeyTypeZ *data; + union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyTypeZZ; + bool result_ok; +} LDKCResult_ChannelUpdateDecodeErrorZ; /** - * The contents of a custom onion message. + * The contents of CResult_ErrorMessageDecodeErrorZ */ -typedef struct LDKCustomOnionMessageContents { +typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKErrorMessage *result; /** - * Returns the TLV type identifying the message contents. MUST be >= 64. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint64_t (*tlv_type)(const void *this_arg); + struct LDKDecodeError *err; +} LDKCResult_ErrorMessageDecodeErrorZPtr; + +/** + * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ErrorMessageDecodeErrorZ { /** - * Serialize the object into a byte array + * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + union LDKCResult_ErrorMessageDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKCustomOnionMessageContents; + bool result_ok; +} LDKCResult_ErrorMessageDecodeErrorZ; /** - * An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not + * The contents of CResult_WarningMessageDecodeErrorZ */ -typedef enum LDKCOption_CustomOnionMessageContentsZ_Tag { +typedef union LDKCResult_WarningMessageDecodeErrorZPtr { /** - * When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_CustomOnionMessageContentsZ_Some, + struct LDKWarningMessage *result; /** - * When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_CustomOnionMessageContentsZ_None, + struct LDKDecodeError *err; +} LDKCResult_WarningMessageDecodeErrorZPtr; + +/** + * A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_WarningMessageDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_CustomOnionMessageContentsZ_Sentinel, -} LDKCOption_CustomOnionMessageContentsZ_Tag; - -typedef struct LDKCOption_CustomOnionMessageContentsZ { - LDKCOption_CustomOnionMessageContentsZ_Tag tag; - union { - struct { - struct LDKCustomOnionMessageContents some; - }; - }; -} LDKCOption_CustomOnionMessageContentsZ; + union LDKCResult_WarningMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_WarningMessageDecodeErrorZ; /** - * The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ + * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ */ -typedef union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_CustomOnionMessageContentsZ *result; + struct LDKUnsignedNodeAnnouncement *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; /** - * A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ { +typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { /** - * The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either + * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr contents; + union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; /** - * Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. + * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ; +} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; /** - * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not + * The contents of CResult_NodeAnnouncementDecodeErrorZ */ -typedef enum LDKCOption_NetAddressZ_Tag { +typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { /** - * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_NetAddressZ_Some, + struct LDKNodeAnnouncement *result; /** - * When we're in this state, this COption_NetAddressZ contains nothing + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_NetAddressZ_None, + struct LDKDecodeError *err; +} LDKCResult_NodeAnnouncementDecodeErrorZPtr; + +/** + * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_NetAddressZ_Sentinel, -} LDKCOption_NetAddressZ_Tag; - -typedef struct LDKCOption_NetAddressZ { - LDKCOption_NetAddressZ_Tag tag; - union { - struct { - struct LDKNetAddress some; - }; - }; -} LDKCOption_NetAddressZ; + union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + /** + * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NodeAnnouncementDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_QueryShortChannelIdsDecodeErrorZ */ -typedef struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ { +typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey a; + struct LDKQueryShortChannelIds *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCOption_NetAddressZ b; -} LDKC2Tuple_PublicKeyCOption_NetAddressZZ; + struct LDKDecodeError *err; +} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { +typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ *data; + union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ; + bool result_ok; +} LDKCResult_QueryShortChannelIdsDecodeErrorZ; /** - * Error for PeerManager errors. If you get one of these, you must disconnect the socket and - * generate no further read_event/write_buffer_space_avail/socket_disconnected calls for the - * descriptor. + * A [`reply_short_channel_ids_end`] message is sent as a reply to a + * message. The query recipient makes a best + * effort to respond based on their local network view which may not be + * a perfect view of the network. + * + * [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages */ -typedef struct MUST_USE_STRUCT LDKPeerHandleError { +typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePeerHandleError *inner; + LDKnativeReplyShortChannelIdsEnd *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerHandleError; +} LDKReplyShortChannelIdsEnd; /** - * The contents of CResult_CVec_u8ZPeerHandleErrorZ + * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ */ -typedef union LDKCResult_CVec_u8ZPeerHandleErrorZPtr { +typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_u8Z *result; + struct LDKReplyShortChannelIdsEnd *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_CVec_u8ZPeerHandleErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; /** - * A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_u8ZPeerHandleErrorZ { +typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { /** - * The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either + * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_u8ZPeerHandleErrorZPtr contents; + union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; /** - * Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_u8ZPeerHandleErrorZ; +} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; /** - * The contents of CResult_NonePeerHandleErrorZ + * The contents of CResult_QueryChannelRangeDecodeErrorZ */ -typedef union LDKCResult_NonePeerHandleErrorZPtr { +typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKQueryChannelRange *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_NonePeerHandleErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_QueryChannelRangeDecodeErrorZPtr; /** - * A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NonePeerHandleErrorZ { +typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { /** - * The contents of this CResult_NonePeerHandleErrorZ, accessible via either + * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePeerHandleErrorZPtr contents; + union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; /** - * Whether this CResult_NonePeerHandleErrorZ represents a success state. + * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NonePeerHandleErrorZ; +} LDKCResult_QueryChannelRangeDecodeErrorZ; /** - * The contents of CResult_boolPeerHandleErrorZ + * The contents of CResult_ReplyChannelRangeDecodeErrorZ */ -typedef union LDKCResult_boolPeerHandleErrorZPtr { +typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - bool *result; + struct LDKReplyChannelRange *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPeerHandleError *err; -} LDKCResult_boolPeerHandleErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; /** - * A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, - * containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. + * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_boolPeerHandleErrorZ { +typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { /** - * The contents of this CResult_boolPeerHandleErrorZ, accessible via either + * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_boolPeerHandleErrorZPtr contents; + union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; /** - * Whether this CResult_boolPeerHandleErrorZ represents a success state. + * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_boolPeerHandleErrorZ; +} LDKCResult_ReplyChannelRangeDecodeErrorZ; /** - * Errors that may occur when [sending an onion message]. - * - * [sending an onion message]: OnionMessenger::send_onion_message + * The contents of CResult_GossipTimestampFilterDecodeErrorZ */ -typedef enum LDKSendError_Tag { - /** - * Errored computing onion message packet keys. - */ - LDKSendError_Secp256k1, +typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { /** - * Because implementations such as Eclair will drop onion messages where the message packet - * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKSendError_TooBigPacket, + struct LDKGossipTimestampFilter *result; /** - * The provided [`Destination`] was an invalid [`BlindedPath`], due to having fewer than two - * blinded hops. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKSendError_TooFewBlindedHops, - /** - * Our next-hop peer was offline or does not support onion message forwarding. - */ - LDKSendError_InvalidFirstHop, - /** - * Onion message contents must have a TLV type >= 64. - */ - LDKSendError_InvalidMessage, - /** - * Our next-hop peer's buffer was full or our total outbound buffer was full. - */ - LDKSendError_BufferFull, - /** - * Failed to retrieve our node id from the provided [`NodeSigner`]. - * - * [`NodeSigner`]: crate::chain::keysinterface::NodeSigner - */ - LDKSendError_GetNodeIdFailed, - /** - * We attempted to send to a blinded path where we are the introduction node, and failed to - * advance the blinded path to make the second hop the new introduction node. Either - * [`NodeSigner::ecdh`] failed, we failed to tweak the current blinding point to get the - * new blinding point, or we were attempting to send to ourselves. - */ - LDKSendError_BlindedPathAdvanceFailed, - /** - * Must be last for serialization purposes - */ - LDKSendError_Sentinel, -} LDKSendError_Tag; - -typedef struct MUST_USE_STRUCT LDKSendError { - LDKSendError_Tag tag; - union { - struct { - enum LDKSecp256k1Error secp256k1; - }; - }; -} LDKSendError; - -/** - * The contents of CResult_NoneSendErrorZ - */ -typedef union LDKCResult_NoneSendErrorZPtr { - /** - * Note that this value is always NULL, as there are no contents in the OK variant - */ - void *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKSendError *err; -} LDKCResult_NoneSendErrorZPtr; - -/** - * A CResult_NoneSendErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneSendErrorZ { - /** - * The contents of this CResult_NoneSendErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneSendErrorZPtr contents; - /** - * Whether this CResult_NoneSendErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NoneSendErrorZ; - -/** - * The contents of CResult_BlindedPathNoneZ - */ -typedef union LDKCResult_BlindedPathNoneZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKBlindedPath *result; - /** - * Note that this value is always NULL, as there are no contents in the Err variant - */ - void *err; -} LDKCResult_BlindedPathNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; /** - * A CResult_BlindedPathNoneZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. + * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedPathNoneZ { +typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { /** - * The contents of this CResult_BlindedPathNoneZ, accessible via either + * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPathNoneZPtr contents; + union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPathNoneZ represents a success state. + * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPathNoneZ; +} LDKCResult_GossipTimestampFilterDecodeErrorZ; /** - * The contents of CResult_BlindedPathDecodeErrorZ + * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_BlindedPathDecodeErrorZPtr { +typedef struct LDKCVec_PhantomRouteHintsZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKBlindedPath *result; + struct LDKPhantomRouteHints *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_BlindedPathDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_PhantomRouteHintsZ; -/** - * A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_BlindedPathDecodeErrorZ { - /** - * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_BlindedPathDecodeErrorZPtr contents; - /** - * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_BlindedPathDecodeErrorZ; -/** - * The contents of CResult_BlindedHopDecodeErrorZ - */ -typedef union LDKCResult_BlindedHopDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKBlindedHop *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_BlindedHopDecodeErrorZPtr; /** - * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Represents a syntactically and semantically correct lightning BOLT11 invoice. + * + * There are three ways to construct a `Bolt11Invoice`: + * 1. using [`InvoiceBuilder`] + * 2. using [`Bolt11Invoice::from_signed`] + * 3. using `str::parse::(&str)` (see [`Bolt11Invoice::from_str`]) + * + * [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr */ -typedef struct LDKCResult_BlindedHopDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKBolt11Invoice { /** - * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_BlindedHopDecodeErrorZPtr contents; + LDKnativeBolt11Invoice *inner; /** - * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_BlindedHopDecodeErrorZ; + bool is_owned; +} LDKBolt11Invoice; /** - * Sub-errors which don't have specific information in them use this type. + * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] + * may occur. */ -typedef struct LDKError { +typedef enum LDKSignOrCreationError_Tag { /** - * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here + * An error occurred during signing */ - uint8_t _dummy; -} LDKError; - -/** - * Errors that indicate what is wrong with the invoice. They have some granularity for debug - * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. - */ -typedef enum LDKParseError_Tag { - LDKParseError_Bech32Error, - LDKParseError_ParseAmountError, - LDKParseError_MalformedSignature, - LDKParseError_BadPrefix, - LDKParseError_UnknownCurrency, - LDKParseError_UnknownSiPrefix, - LDKParseError_MalformedHRP, - LDKParseError_TooShortDataPart, - LDKParseError_UnexpectedEndOfTaggedFields, - LDKParseError_DescriptionDecodeError, - LDKParseError_PaddingError, - LDKParseError_IntegerOverflowError, - LDKParseError_InvalidSegWitProgramLength, - LDKParseError_InvalidPubKeyHashLength, - LDKParseError_InvalidScriptHashLength, - LDKParseError_InvalidRecoveryId, - LDKParseError_InvalidSliceLength, + LDKSignOrCreationError_SignError, /** - * Not an error, but used internally to signal that a part of the invoice should be ignored - * according to BOLT11 + * An error occurred while building the transaction */ - LDKParseError_Skip, + LDKSignOrCreationError_CreationError, /** * Must be last for serialization purposes */ - LDKParseError_Sentinel, -} LDKParseError_Tag; + LDKSignOrCreationError_Sentinel, +} LDKSignOrCreationError_Tag; -typedef struct MUST_USE_STRUCT LDKParseError { - LDKParseError_Tag tag; +typedef struct MUST_USE_STRUCT LDKSignOrCreationError { + LDKSignOrCreationError_Tag tag; union { struct { - struct LDKBech32Error bech32_error; - }; - struct { - struct LDKError parse_amount_error; - }; - struct { - enum LDKSecp256k1Error malformed_signature; - }; - struct { - struct LDKError description_decode_error; - }; - struct { - struct LDKStr invalid_slice_length; + enum LDKCreationError creation_error; }; }; -} LDKParseError; +} LDKSignOrCreationError; /** - * The contents of CResult_SiPrefixParseErrorZ + * The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ */ -typedef union LDKCResult_SiPrefixParseErrorZPtr { +typedef union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - enum LDKSiPrefix *result; + struct LDKBolt11Invoice *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKParseError *err; -} LDKCResult_SiPrefixParseErrorZPtr; + struct LDKSignOrCreationError *err; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr; /** - * A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. + * A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SiPrefixParseErrorZ { +typedef struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ { /** - * The contents of this CResult_SiPrefixParseErrorZ, accessible via either + * The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SiPrefixParseErrorZPtr contents; + union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr contents; /** - * Whether this CResult_SiPrefixParseErrorZ represents a success state. + * Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SiPrefixParseErrorZ; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZ; /** - * Represents a syntactically and semantically correct lightning BOLT11 invoice. - * - * There are three ways to construct an `Invoice`: - * 1. using [`InvoiceBuilder`] - * 2. using [`Invoice::from_signed`] - * 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) + * A simple future which can complete once, and calls some callback(s) when it does so. * - * [`Invoice::from_str`]: crate::Invoice#impl-FromStr + * Clones can be made and all futures cloned from the same source will complete at the same time. */ -typedef struct MUST_USE_STRUCT LDKInvoice { +typedef struct MUST_USE_STRUCT LDKFuture { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoice *inner; + LDKnativeFuture *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoice; +} LDKFuture; /** - * Indicates that something went wrong while parsing or validating the invoice. Parsing errors - * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors - * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. + * A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKParseOrSemanticError_Tag { - /** - * The invoice couldn't be decoded - */ - LDKParseOrSemanticError_ParseError, +typedef struct LDKCVec_FutureZ { /** - * The invoice could be decoded but violates the BOLT11 standard + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKParseOrSemanticError_SemanticError, + struct LDKFuture *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKParseOrSemanticError_Sentinel, -} LDKParseOrSemanticError_Tag; - -typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { - LDKParseOrSemanticError_Tag tag; - union { - struct { - struct LDKParseError parse_error; - }; - struct { - enum LDKSemanticError semantic_error; - }; - }; -} LDKParseOrSemanticError; + uintptr_t datalen; +} LDKCVec_FutureZ; /** - * The contents of CResult_InvoiceParseOrSemanticErrorZ + * The contents of CResult_OffersMessageDecodeErrorZ */ -typedef union LDKCResult_InvoiceParseOrSemanticErrorZPtr { +typedef union LDKCResult_OffersMessageDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoice *result; + struct LDKOffersMessage *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKParseOrSemanticError *err; -} LDKCResult_InvoiceParseOrSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_OffersMessageDecodeErrorZPtr; /** - * A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. + * A CResult_OffersMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::offers::OffersMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { +typedef struct LDKCResult_OffersMessageDecodeErrorZ { /** - * The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either + * The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceParseOrSemanticErrorZPtr contents; + union LDKCResult_OffersMessageDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. + * Whether this CResult_OffersMessageDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceParseOrSemanticErrorZ; +} LDKCResult_OffersMessageDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not + */ +typedef enum LDKCOption_HTLCClaimZ_Tag { + /** + * When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + */ + LDKCOption_HTLCClaimZ_Some, + /** + * When we're in this state, this COption_HTLCClaimZ contains nothing + */ + LDKCOption_HTLCClaimZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_HTLCClaimZ_Sentinel, +} LDKCOption_HTLCClaimZ_Tag; + +typedef struct LDKCOption_HTLCClaimZ { + LDKCOption_HTLCClaimZ_Tag tag; + union { + struct { + enum LDKHTLCClaim some; + }; + }; +} LDKCOption_HTLCClaimZ; /** - * Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be - * invalid. + * Implements the per-commitment secret storage scheme from + * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). * - * # Invariants - * The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. + * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes + * or so. */ -typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { +typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSignedRawInvoice *inner; + LDKnativeCounterpartyCommitmentSecrets *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSignedRawInvoice; +} LDKCounterpartyCommitmentSecrets; /** - * The contents of CResult_SignedRawInvoiceParseErrorZ + * The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ */ -typedef union LDKCResult_SignedRawInvoiceParseErrorZPtr { +typedef union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSignedRawInvoice *result; + struct LDKCounterpartyCommitmentSecrets *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKParseError *err; -} LDKCResult_SignedRawInvoiceParseErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr; /** - * A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. + * A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { +typedef struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ { /** - * The contents of this CResult_SignedRawInvoiceParseErrorZ, accessible via either + * The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignedRawInvoiceParseErrorZPtr contents; + union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr contents; /** - * Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. + * Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SignedRawInvoiceParseErrorZ; +} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ; /** - * Represents an syntactically correct [`Invoice`] for a payment on the lightning network, - * but without the signature information. - * Decoding and encoding should not lead to information loss but may lead to different hashes. + * The set of public keys which are used in the creation of one commitment transaction. + * These are derived from the channel base keys and per-commitment data. * - * For methods without docs see the corresponding methods in [`Invoice`]. - */ -typedef struct MUST_USE_STRUCT LDKRawInvoice { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRawInvoice *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRawInvoice; - - - -/** - * Recoverable signature + * A broadcaster key is provided from potential broadcaster of the computed transaction. + * A countersignatory key is coming from a protocol participant unable to broadcast the + * transaction. + * + * These keys are assumed to be good, either because the code derived them from + * channel basepoints via the new function, or they were obtained via + * CommitmentTransaction.trust().keys() because we trusted the source of the + * pre-calculated keys. */ -typedef struct MUST_USE_STRUCT LDKInvoiceSignature { +typedef struct MUST_USE_STRUCT LDKTxCreationKeys { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceSignature *inner; + LDKnativeTxCreationKeys *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceSignature; +} LDKTxCreationKeys; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * The contents of CResult_TxCreationKeysDecodeErrorZ */ -typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { - /** - * The element at position 0 - */ - struct LDKRawInvoice a; +typedef union LDKCResult_TxCreationKeysDecodeErrorZPtr { /** - * The element at position 1 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes b; + struct LDKTxCreationKeys *result; /** - * The element at position 2 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKInvoiceSignature c; -} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; - - + struct LDKDecodeError *err; +} LDKCResult_TxCreationKeysDecodeErrorZPtr; /** - * Payee public key + * A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKPayeePubKey { +typedef struct LDKCResult_TxCreationKeysDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativePayeePubKey *inner; + union LDKCResult_TxCreationKeysDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKPayeePubKey; + bool result_ok; +} LDKCResult_TxCreationKeysDecodeErrorZ; /** - * The contents of CResult_PayeePubKeyErrorZ + * The contents of CResult_ChannelPublicKeysDecodeErrorZ */ -typedef union LDKCResult_PayeePubKeyErrorZPtr { +typedef union LDKCResult_ChannelPublicKeysDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPayeePubKey *result; + struct LDKChannelPublicKeys *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSecp256k1Error *err; -} LDKCResult_PayeePubKeyErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelPublicKeysDecodeErrorZPtr; /** - * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PayeePubKeyErrorZ { +typedef struct LDKCResult_ChannelPublicKeysDecodeErrorZ { /** - * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PayeePubKeyErrorZPtr contents; + union LDKCResult_ChannelPublicKeysDecodeErrorZPtr contents; /** - * Whether this CResult_PayeePubKeyErrorZ represents a success state. + * Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PayeePubKeyErrorZ; - - +} LDKCResult_ChannelPublicKeysDecodeErrorZ; /** - * Private routing information - * - * # Invariants - * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) - * + * The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKPrivateRoute { +typedef union LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativePrivateRoute *inner; + struct LDKHTLCOutputInCommitment *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKPrivateRoute; + struct LDKDecodeError *err; +} LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_PrivateRouteZ { +typedef struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPrivateRoute *data; + union LDKCResult_HTLCOutputInCommitmentDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_PrivateRouteZ; + bool result_ok; +} LDKCResult_HTLCOutputInCommitmentDecodeErrorZ; /** - * A timestamp that refers to a date after 1 January 1970. - * - * # Invariants - * - * The Unix timestamp representing the stored time has to be positive and no greater than - * [`MAX_TIMESTAMP`]. + * Late-bound per-channel counterparty data used to build transactions. */ -typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { +typedef struct MUST_USE_STRUCT LDKCounterpartyChannelTransactionParameters { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePositiveTimestamp *inner; + LDKnativeCounterpartyChannelTransactionParameters *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPositiveTimestamp; +} LDKCounterpartyChannelTransactionParameters; /** - * The contents of CResult_PositiveTimestampCreationErrorZ + * The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ */ -typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { +typedef union LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPositiveTimestamp *result; + struct LDKCounterpartyChannelTransactionParameters *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_PositiveTimestampCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr; /** - * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PositiveTimestampCreationErrorZ { +typedef struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ { /** - * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PositiveTimestampCreationErrorZPtr contents; + union LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr contents; /** - * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + * Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PositiveTimestampCreationErrorZ; +} LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ; /** - * The contents of CResult_NoneSemanticErrorZ + * The contents of CResult_ChannelTransactionParametersDecodeErrorZ */ -typedef union LDKCResult_NoneSemanticErrorZPtr { +typedef union LDKCResult_ChannelTransactionParametersDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKChannelTransactionParameters *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSemanticError *err; -} LDKCResult_NoneSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelTransactionParametersDecodeErrorZPtr; /** - * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneSemanticErrorZ { +typedef struct LDKCResult_ChannelTransactionParametersDecodeErrorZ { /** - * The contents of this CResult_NoneSemanticErrorZ, accessible via either + * The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneSemanticErrorZPtr contents; + union LDKCResult_ChannelTransactionParametersDecodeErrorZPtr contents; /** - * Whether this CResult_NoneSemanticErrorZ represents a success state. + * Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneSemanticErrorZ; +} LDKCResult_ChannelTransactionParametersDecodeErrorZ; /** - * The contents of CResult_InvoiceSemanticErrorZ + * The contents of CResult_HolderCommitmentTransactionDecodeErrorZ */ -typedef union LDKCResult_InvoiceSemanticErrorZPtr { +typedef union LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoice *result; + struct LDKHolderCommitmentTransaction *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSemanticError *err; -} LDKCResult_InvoiceSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr; /** - * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceSemanticErrorZ { +typedef struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ { /** - * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + * The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceSemanticErrorZPtr contents; + union LDKCResult_HolderCommitmentTransactionDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceSemanticErrorZ represents a success state. + * Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceSemanticErrorZ; +} LDKCResult_HolderCommitmentTransactionDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. - * This corresponds to std::vector in C++ + * A pre-built Bitcoin commitment transaction and its txid. */ -typedef struct LDKCVec_AddressZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKStr *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_AddressZ; - - - -/** - * Description string - * - * # Invariants - * The description can be at most 639 __bytes__ long - */ -typedef struct MUST_USE_STRUCT LDKDescription { +typedef struct MUST_USE_STRUCT LDKBuiltCommitmentTransaction { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDescription *inner; + LDKnativeBuiltCommitmentTransaction *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDescription; +} LDKBuiltCommitmentTransaction; /** - * The contents of CResult_DescriptionCreationErrorZ + * The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ */ -typedef union LDKCResult_DescriptionCreationErrorZPtr { +typedef union LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKDescription *result; + struct LDKBuiltCommitmentTransaction *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_DescriptionCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr; /** - * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_DescriptionCreationErrorZ { +typedef struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ { /** - * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_DescriptionCreationErrorZPtr contents; + union LDKCResult_BuiltCommitmentTransactionDecodeErrorZPtr contents; /** - * Whether this CResult_DescriptionCreationErrorZ represents a success state. + * Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_DescriptionCreationErrorZ; +} LDKCResult_BuiltCommitmentTransactionDecodeErrorZ; + + /** - * The contents of CResult_PrivateRouteCreationErrorZ + * A wrapper on ClosingTransaction indicating that the built bitcoin + * transaction is trusted. + * + * See trust() and verify() functions on CommitmentTransaction. + * + * This structure implements Deref. */ -typedef union LDKCResult_PrivateRouteCreationErrorZPtr { +typedef struct MUST_USE_STRUCT LDKTrustedClosingTransaction { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeTrustedClosingTransaction *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKTrustedClosingTransaction; + +/** + * The contents of CResult_TrustedClosingTransactionNoneZ + */ +typedef union LDKCResult_TrustedClosingTransactionNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPrivateRoute *result; + struct LDKTrustedClosingTransaction *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - enum LDKCreationError *err; -} LDKCResult_PrivateRouteCreationErrorZPtr; + void *err; +} LDKCResult_TrustedClosingTransactionNoneZPtr; /** - * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PrivateRouteCreationErrorZ { +typedef struct LDKCResult_TrustedClosingTransactionNoneZ { /** - * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either + * The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PrivateRouteCreationErrorZPtr contents; + union LDKCResult_TrustedClosingTransactionNoneZPtr contents; /** - * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + * Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PrivateRouteCreationErrorZ; +} LDKCResult_TrustedClosingTransactionNoneZ; /** - * The contents of CResult_NetAddressDecodeErrorZ + * The contents of CResult_CommitmentTransactionDecodeErrorZ */ -typedef union LDKCResult_NetAddressDecodeErrorZPtr { +typedef union LDKCResult_CommitmentTransactionDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNetAddress *result; + struct LDKCommitmentTransaction *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_NetAddressDecodeErrorZPtr; +} LDKCResult_CommitmentTransactionDecodeErrorZPtr; /** - * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NetAddressDecodeErrorZ { +typedef struct LDKCResult_CommitmentTransactionDecodeErrorZ { /** - * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either + * The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NetAddressDecodeErrorZPtr contents; + union LDKCResult_CommitmentTransactionDecodeErrorZPtr contents; /** - * Whether this CResult_NetAddressDecodeErrorZ represents a success state. + * Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NetAddressDecodeErrorZ; +} LDKCResult_CommitmentTransactionDecodeErrorZ; /** - * An [`update_add_htlc`] message to be sent to or received from a peer. + * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin + * transaction and the transaction creation keys) are trusted. * - * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc + * See trust() and verify() functions on CommitmentTransaction. + * + * This structure implements Deref. */ -typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { +typedef struct MUST_USE_STRUCT LDKTrustedCommitmentTransaction { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateAddHTLC *inner; + LDKnativeTrustedCommitmentTransaction *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateAddHTLC; +} LDKTrustedCommitmentTransaction; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_TrustedCommitmentTransactionNoneZ */ -typedef struct LDKCVec_UpdateAddHTLCZ { +typedef union LDKCResult_TrustedCommitmentTransactionNoneZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateAddHTLC *data; + struct LDKTrustedCommitmentTransaction *result; /** - * The number of elements pointed to by `data`. + * Note that this value is always NULL, as there are no contents in the Err variant */ - uintptr_t datalen; -} LDKCVec_UpdateAddHTLCZ; - - + void *err; +} LDKCResult_TrustedCommitmentTransactionNoneZPtr; /** - * An [`update_fulfill_htlc`] message to be sent to or received from a peer. - * - * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc + * A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { +typedef struct LDKCResult_TrustedCommitmentTransactionNoneZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeUpdateFulfillHTLC *inner; + union LDKCResult_TrustedCommitmentTransactionNoneZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. */ - bool is_owned; -} LDKUpdateFulfillHTLC; + bool result_ok; +} LDKCResult_TrustedCommitmentTransactionNoneZ; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_CVec_SignatureZNoneZ */ -typedef struct LDKCVec_UpdateFulfillHTLCZ { +typedef union LDKCResult_CVec_SignatureZNoneZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUpdateFulfillHTLC *data; + struct LDKCVec_SignatureZ *result; /** - * The number of elements pointed to by `data`. + * Note that this value is always NULL, as there are no contents in the Err variant */ - uintptr_t datalen; -} LDKCVec_UpdateFulfillHTLCZ; - + void *err; +} LDKCResult_CVec_SignatureZNoneZPtr; +/** + * A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CVec_SignatureZNoneZ { + /** + * The contents of this CResult_CVec_SignatureZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CVec_SignatureZNoneZPtr contents; + /** + * Whether this CResult_CVec_SignatureZNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_CVec_SignatureZNoneZ; /** - * An [`update_fail_htlc`] message to be sent to or received from a peer. - * - * [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc + * The contents of CResult_ShutdownScriptDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { +typedef union LDKCResult_ShutdownScriptDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeUpdateFailHTLC *inner; + struct LDKShutdownScript *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKUpdateFailHTLC; + struct LDKDecodeError *err; +} LDKCResult_ShutdownScriptDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_UpdateFailHTLCZ { +typedef struct LDKCResult_ShutdownScriptDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKUpdateFailHTLC *data; + union LDKCResult_ShutdownScriptDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_UpdateFailHTLCZ; + bool result_ok; +} LDKCResult_ShutdownScriptDecodeErrorZ; /** - * An [`update_fail_malformed_htlc`] message to be sent to or received from a peer. - * - * [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc + * An error occurring when converting from [`Script`] to [`ShutdownScript`]. */ -typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { +typedef struct MUST_USE_STRUCT LDKInvalidShutdownScript { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFailMalformedHTLC *inner; + LDKnativeInvalidShutdownScript *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFailMalformedHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFailMalformedHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFailMalformedHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFailMalformedHTLCZ; +} LDKInvalidShutdownScript; /** - * The contents of CResult_AcceptChannelDecodeErrorZ + * The contents of CResult_ShutdownScriptInvalidShutdownScriptZ */ -typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { +typedef union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKAcceptChannel *result; + struct LDKShutdownScript *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_AcceptChannelDecodeErrorZPtr; + struct LDKInvalidShutdownScript *err; +} LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr; /** - * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, + * containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_AcceptChannelDecodeErrorZ { +typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { /** - * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + * The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_AcceptChannelDecodeErrorZPtr contents; + union LDKCResult_ShutdownScriptInvalidShutdownScriptZPtr contents; /** - * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + * Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. */ bool result_ok; -} LDKCResult_AcceptChannelDecodeErrorZ; +} LDKCResult_ShutdownScriptInvalidShutdownScriptZ; /** - * The contents of CResult_AnnouncementSignaturesDecodeErrorZ + * Some information provided on receipt of payment depends on whether the payment received is a + * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. */ -typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { +typedef enum LDKPaymentPurpose_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Information for receiving a payment that we generated an invoice for. */ - struct LDKAnnouncementSignatures *result; + LDKPaymentPurpose_InvoicePayment, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Because this is a spontaneous payment, the payer generated their own preimage rather than us + * (the payee) providing a preimage. */ - struct LDKDecodeError *err; -} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; + LDKPaymentPurpose_SpontaneousPayment, + /** + * Must be last for serialization purposes + */ + LDKPaymentPurpose_Sentinel, +} LDKPaymentPurpose_Tag; -/** - * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { +typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { /** - * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The preimage to the payment_hash, if the payment hash (and secret) were fetched via + * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + * [`ChannelManager::claim_funds`]. + * + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ - union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; + struct LDKCOption_PaymentPreimageZ payment_preimage; /** - * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + * The \"payment secret\". This authenticates the sender to the recipient, preventing a + * number of deanonymization attacks during the routing process. + * It is provided here for your reference, however its accuracy is enforced directly by + * [`ChannelManager`] using the values you previously provided to + * [`ChannelManager::create_inbound_payment`] or + * [`ChannelManager::create_inbound_payment_for_hash`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ - bool result_ok; -} LDKCResult_AnnouncementSignaturesDecodeErrorZ; + struct LDKThirtyTwoBytes payment_secret; +} LDKPaymentPurpose_LDKInvoicePayment_Body; + +typedef struct MUST_USE_STRUCT LDKPaymentPurpose { + LDKPaymentPurpose_Tag tag; + union { + LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; + struct { + struct LDKThirtyTwoBytes spontaneous_payment; + }; + }; +} LDKPaymentPurpose; /** - * The contents of CResult_ChannelReestablishDecodeErrorZ + * The contents of CResult_PaymentPurposeDecodeErrorZ */ -typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { +typedef union LDKCResult_PaymentPurposeDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelReestablish *result; + struct LDKPaymentPurpose *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelReestablishDecodeErrorZPtr; +} LDKCResult_PaymentPurposeDecodeErrorZPtr; /** - * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { +typedef struct LDKCResult_PaymentPurposeDecodeErrorZ { /** - * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; + union LDKCResult_PaymentPurposeDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + * Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelReestablishDecodeErrorZ; +} LDKCResult_PaymentPurposeDecodeErrorZ; /** - * The contents of CResult_ClosingSignedDecodeErrorZ + * When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may + * contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. + * + * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ -typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { +typedef enum LDKPathFailure_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * We failed to initially send the payment and no HTLC was committed to. Contains the relevant + * error. */ - struct LDKClosingSigned *result; + LDKPathFailure_InitialSend, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * A hop on the path failed to forward our payment. */ - struct LDKDecodeError *err; -} LDKCResult_ClosingSignedDecodeErrorZPtr; - -/** - * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ClosingSignedDecodeErrorZ { + LDKPathFailure_OnPath, /** - * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Must be last for serialization purposes */ - union LDKCResult_ClosingSignedDecodeErrorZPtr contents; + LDKPathFailure_Sentinel, +} LDKPathFailure_Tag; + +typedef struct LDKPathFailure_LDKInitialSend_Body { /** - * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + * The error surfaced from initial send. */ - bool result_ok; -} LDKCResult_ClosingSignedDecodeErrorZ; + struct LDKAPIError err; +} LDKPathFailure_LDKInitialSend_Body; +typedef struct LDKPathFailure_LDKOnPath_Body { + /** + * If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing + * decisions can take into account the update. + * + * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + */ + struct LDKCOption_NetworkUpdateZ network_update; +} LDKPathFailure_LDKOnPath_Body; +typedef struct MUST_USE_STRUCT LDKPathFailure { + LDKPathFailure_Tag tag; + union { + LDKPathFailure_LDKInitialSend_Body initial_send; + LDKPathFailure_LDKOnPath_Body on_path; + }; +} LDKPathFailure; /** - * The minimum and maximum fees which the sender is willing to place on the closing transaction. - * - * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing - * to use. + * An enum which can either contain a crate::lightning::events::PathFailure or not */ -typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange { +typedef enum LDKCOption_PathFailureZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure */ - LDKnativeClosingSignedFeeRange *inner; + LDKCOption_PathFailureZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_PathFailureZ contains nothing */ - bool is_owned; -} LDKClosingSignedFeeRange; + LDKCOption_PathFailureZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PathFailureZ_Sentinel, +} LDKCOption_PathFailureZ_Tag; + +typedef struct LDKCOption_PathFailureZ { + LDKCOption_PathFailureZ_Tag tag; + union { + struct { + struct LDKPathFailure some; + }; + }; +} LDKCOption_PathFailureZ; /** - * The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ + * The contents of CResult_COption_PathFailureZDecodeErrorZ */ -typedef union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr { +typedef union LDKCResult_COption_PathFailureZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKClosingSignedFeeRange *result; + struct LDKCOption_PathFailureZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr; +} LDKCResult_COption_PathFailureZDecodeErrorZPtr; /** - * A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { +typedef struct LDKCResult_COption_PathFailureZDecodeErrorZ { /** - * The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either + * The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ClosingSignedFeeRangeDecodeErrorZPtr contents; + union LDKCResult_COption_PathFailureZDecodeErrorZPtr contents; /** - * Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + * Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ClosingSignedFeeRangeDecodeErrorZ; +} LDKCResult_COption_PathFailureZDecodeErrorZ; /** - * A [`commitment_signed`] message to be sent to or received from a peer. - * - * [`commitment_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#committing-updates-so-far-commitment_signed + * Struct to `Display` fields in a safe way using `PrintableString` */ -typedef struct MUST_USE_STRUCT LDKCommitmentSigned { +typedef struct MUST_USE_STRUCT LDKUntrustedString { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCommitmentSigned *inner; + LDKnativeUntrustedString *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCommitmentSigned; +} LDKUntrustedString; /** - * The contents of CResult_CommitmentSignedDecodeErrorZ + * The reason the channel was closed. See individual variants for more details. */ -typedef union LDKCResult_CommitmentSignedDecodeErrorZPtr { +typedef enum LDKClosureReason_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Closure generated from receiving a peer error message. + * + * Our counterparty may have broadcasted their latest commitment state, and we have + * as well. */ - struct LDKCommitmentSigned *result; + LDKClosureReason_CounterpartyForceClosed, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Closure generated from [`ChannelManager::force_close_channel`], called by the user. + * + * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. */ - struct LDKDecodeError *err; -} LDKCResult_CommitmentSignedDecodeErrorZPtr; - -/** - * A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_CommitmentSignedDecodeErrorZ { + LDKClosureReason_HolderForceClosed, /** - * The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The channel was closed after negotiating a cooperative close and we've now broadcasted + * the cooperative close transaction. Note the shutdown may have been initiated by us. */ - union LDKCResult_CommitmentSignedDecodeErrorZPtr contents; + LDKClosureReason_CooperativeClosure, /** - * Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + * A commitment transaction was confirmed on chain, closing the channel. Most likely this + * commitment transaction came from our counterparty, but it may also have come from + * a copy of our own `ChannelMonitor`. */ - bool result_ok; -} LDKCResult_CommitmentSignedDecodeErrorZ; - -/** - * The contents of CResult_FundingCreatedDecodeErrorZ - */ -typedef union LDKCResult_FundingCreatedDecodeErrorZPtr { + LDKClosureReason_CommitmentTxConfirmed, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The funding transaction failed to confirm in a timely manner on an inbound channel. */ - struct LDKFundingCreated *result; + LDKClosureReason_FundingTimedOut, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Closure generated from processing an event, likely a HTLC forward/relay/reception. */ - struct LDKDecodeError *err; -} LDKCResult_FundingCreatedDecodeErrorZPtr; - -/** - * A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_FundingCreatedDecodeErrorZ { + LDKClosureReason_ProcessingError, /** - * The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The peer disconnected prior to funding completing. In this case the spec mandates that we + * forget the channel entirely - we can attempt again if the peer reconnects. + * + * This includes cases where we restarted prior to funding completion, including prior to the + * initial [`ChannelMonitor`] persistence completing. + * + * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + * peer because of mutual incompatibility between us and our channel counterparty. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ - union LDKCResult_FundingCreatedDecodeErrorZPtr contents; + LDKClosureReason_DisconnectedPeer, /** - * Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than + * the [`ChannelManager`] deserialized. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - bool result_ok; -} LDKCResult_FundingCreatedDecodeErrorZ; + LDKClosureReason_OutdatedChannelManager, + /** + * The counterparty requested a cooperative close of a channel that had not been funded yet. + * The channel has been immediately closed. + */ + LDKClosureReason_CounterpartyCoopClosedUnfundedChannel, + /** + * Must be last for serialization purposes + */ + LDKClosureReason_Sentinel, +} LDKClosureReason_Tag; -/** - * The contents of CResult_FundingSignedDecodeErrorZ - */ -typedef union LDKCResult_FundingSignedDecodeErrorZPtr { +typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The error which the peer sent us. + * + * Be careful about printing the peer_msg, a well-crafted message could exploit + * a security vulnerability in the terminal emulator or the logging subsystem. + * To be safe, use `Display` on `UntrustedString` + * + * [`UntrustedString`]: crate::util::string::UntrustedString */ - struct LDKFundingSigned *result; + struct LDKUntrustedString peer_msg; +} LDKClosureReason_LDKCounterpartyForceClosed_Body; + +typedef struct LDKClosureReason_LDKProcessingError_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * A developer-readable error message which we generated. */ - struct LDKDecodeError *err; -} LDKCResult_FundingSignedDecodeErrorZPtr; + struct LDKStr err; +} LDKClosureReason_LDKProcessingError_Body; + +typedef struct MUST_USE_STRUCT LDKClosureReason { + LDKClosureReason_Tag tag; + union { + LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; + LDKClosureReason_LDKProcessingError_Body processing_error; + }; +} LDKClosureReason; /** - * A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::lightning::events::ClosureReason or not */ -typedef struct LDKCResult_FundingSignedDecodeErrorZ { +typedef enum LDKCOption_ClosureReasonZ_Tag { /** - * The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason */ - union LDKCResult_FundingSignedDecodeErrorZPtr contents; + LDKCOption_ClosureReasonZ_Some, /** - * Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + * When we're in this state, this COption_ClosureReasonZ contains nothing */ - bool result_ok; -} LDKCResult_FundingSignedDecodeErrorZ; + LDKCOption_ClosureReasonZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ClosureReasonZ_Sentinel, +} LDKCOption_ClosureReasonZ_Tag; + +typedef struct LDKCOption_ClosureReasonZ { + LDKCOption_ClosureReasonZ_Tag tag; + union { + struct { + struct LDKClosureReason some; + }; + }; +} LDKCOption_ClosureReasonZ; /** - * The contents of CResult_ChannelReadyDecodeErrorZ + * The contents of CResult_COption_ClosureReasonZDecodeErrorZ */ -typedef union LDKCResult_ChannelReadyDecodeErrorZPtr { +typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelReady *result; + struct LDKCOption_ClosureReasonZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ChannelReadyDecodeErrorZPtr; +} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr; /** - * A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelReadyDecodeErrorZ { +typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { /** - * The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either + * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelReadyDecodeErrorZPtr contents; + union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelReadyDecodeErrorZ; - - +} LDKCResult_COption_ClosureReasonZDecodeErrorZ; /** - * An [`init`] message to be sent to or received from a peer. - * - * [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message + * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. */ -typedef struct MUST_USE_STRUCT LDKInit { +typedef enum LDKHTLCDestination_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * We tried forwarding to a channel but failed to do so. An example of such an instance is when + * there is insufficient capacity in our outbound channel. */ - LDKnativeInit *inner; + LDKHTLCDestination_NextHopChannel, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Scenario where we are unsure of the next node to forward the HTLC to. */ - bool is_owned; -} LDKInit; - -/** - * The contents of CResult_InitDecodeErrorZ - */ -typedef union LDKCResult_InitDecodeErrorZPtr { + LDKHTLCDestination_UnknownNextHop, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate + * intercept HTLC. */ - struct LDKInit *result; + LDKHTLCDestination_InvalidForward, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Failure scenario where an HTLC may have been forwarded to be intended for us, + * but is invalid for some reason, so we reject it. + * + * Some of the reasons may include: + * * HTLC Timeouts + * * Excess HTLCs for a payment that we have already fully received, over-paying for the + * payment, + * * The counterparty node modified the HTLC in transit, + * * A probing attack where an intermediary node is trying to detect if we are the ultimate + * recipient for a payment. */ - struct LDKDecodeError *err; -} LDKCResult_InitDecodeErrorZPtr; + LDKHTLCDestination_FailedPayment, + /** + * Must be last for serialization purposes + */ + LDKHTLCDestination_Sentinel, +} LDKHTLCDestination_Tag; -/** - * A CResult_InitDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_InitDecodeErrorZ { +typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { /** - * The contents of this CResult_InitDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The `node_id` of the next node. For backwards compatibility, this field is + * marked as optional, versions prior to 0.0.110 may not always be able to provide + * counterparty node information. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - union LDKCResult_InitDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_InitDecodeErrorZ represents a success state. + * The outgoing `channel_id` between us and the next node. */ - bool result_ok; -} LDKCResult_InitDecodeErrorZ; + struct LDKThirtyTwoBytes channel_id; +} LDKHTLCDestination_LDKNextHopChannel_Body; -/** - * The contents of CResult_OpenChannelDecodeErrorZ - */ -typedef union LDKCResult_OpenChannelDecodeErrorZPtr { +typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Short channel id we are requesting to forward an HTLC to. */ - struct LDKOpenChannel *result; + uint64_t requested_forward_scid; +} LDKHTLCDestination_LDKUnknownNextHop_Body; + +typedef struct LDKHTLCDestination_LDKInvalidForward_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Short channel id we are requesting to forward an HTLC to. */ - struct LDKDecodeError *err; -} LDKCResult_OpenChannelDecodeErrorZPtr; + uint64_t requested_forward_scid; +} LDKHTLCDestination_LDKInvalidForward_Body; + +typedef struct LDKHTLCDestination_LDKFailedPayment_Body { + /** + * The payment hash of the payment we attempted to process. + */ + struct LDKThirtyTwoBytes payment_hash; +} LDKHTLCDestination_LDKFailedPayment_Body; + +typedef struct MUST_USE_STRUCT LDKHTLCDestination { + LDKHTLCDestination_Tag tag; + union { + LDKHTLCDestination_LDKNextHopChannel_Body next_hop_channel; + LDKHTLCDestination_LDKUnknownNextHop_Body unknown_next_hop; + LDKHTLCDestination_LDKInvalidForward_Body invalid_forward; + LDKHTLCDestination_LDKFailedPayment_Body failed_payment; + }; +} LDKHTLCDestination; /** - * A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::lightning::events::HTLCDestination or not */ -typedef struct LDKCResult_OpenChannelDecodeErrorZ { +typedef enum LDKCOption_HTLCDestinationZ_Tag { /** - * The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination */ - union LDKCResult_OpenChannelDecodeErrorZPtr contents; + LDKCOption_HTLCDestinationZ_Some, /** - * Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + * When we're in this state, this COption_HTLCDestinationZ contains nothing */ - bool result_ok; -} LDKCResult_OpenChannelDecodeErrorZ; + LDKCOption_HTLCDestinationZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_HTLCDestinationZ_Sentinel, +} LDKCOption_HTLCDestinationZ_Tag; + +typedef struct LDKCOption_HTLCDestinationZ { + LDKCOption_HTLCDestinationZ_Tag tag; + union { + struct { + struct LDKHTLCDestination some; + }; + }; +} LDKCOption_HTLCDestinationZ; /** - * The contents of CResult_RevokeAndACKDecodeErrorZ + * The contents of CResult_COption_HTLCDestinationZDecodeErrorZ */ -typedef union LDKCResult_RevokeAndACKDecodeErrorZPtr { +typedef union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKRevokeAndACK *result; + struct LDKCOption_HTLCDestinationZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_RevokeAndACKDecodeErrorZPtr; +} LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr; /** - * A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_RevokeAndACKDecodeErrorZ { +typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { /** - * The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + * The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_RevokeAndACKDecodeErrorZPtr contents; + union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr contents; /** - * Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + * Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_RevokeAndACKDecodeErrorZ; +} LDKCResult_COption_HTLCDestinationZDecodeErrorZ; /** - * The contents of CResult_ShutdownDecodeErrorZ + * The contents of CResult_PaymentFailureReasonDecodeErrorZ */ -typedef union LDKCResult_ShutdownDecodeErrorZPtr { +typedef union LDKCResult_PaymentFailureReasonDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKShutdown *result; + enum LDKPaymentFailureReason *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_ShutdownDecodeErrorZPtr; +} LDKCResult_PaymentFailureReasonDecodeErrorZPtr; /** - * A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ShutdownDecodeErrorZ { +typedef struct LDKCResult_PaymentFailureReasonDecodeErrorZ { /** - * The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ShutdownDecodeErrorZPtr contents; + union LDKCResult_PaymentFailureReasonDecodeErrorZPtr contents; /** - * Whether this CResult_ShutdownDecodeErrorZ represents a success state. + * Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ShutdownDecodeErrorZ; +} LDKCResult_PaymentFailureReasonDecodeErrorZ; /** - * The contents of CResult_UpdateFailHTLCDecodeErrorZ + * An enum which can either contain a crate::c_types::U128 or not */ -typedef union LDKCResult_UpdateFailHTLCDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKUpdateFailHTLC *result; +typedef enum LDKCOption_u128Z_Tag { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * When we're in this state, this COption_u128Z contains a crate::c_types::U128 */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFailHTLCDecodeErrorZPtr; - -/** - * A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UpdateFailHTLCDecodeErrorZ { + LDKCOption_u128Z_Some, /** - * The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_u128Z contains nothing */ - union LDKCResult_UpdateFailHTLCDecodeErrorZPtr contents; + LDKCOption_u128Z_None, /** - * Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_UpdateFailHTLCDecodeErrorZ; + LDKCOption_u128Z_Sentinel, +} LDKCOption_u128Z_Tag; + +typedef struct LDKCOption_u128Z { + LDKCOption_u128Z_Tag tag; + union { + struct { + struct LDKU128 some; + }; + }; +} LDKCOption_u128Z; /** - * The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ + * An enum which can either contain a crate::c_types::ThirtyTwoBytes or not */ -typedef union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +typedef enum LDKCOption_PaymentIdZ_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * When we're in this state, this COption_PaymentIdZ contains a crate::c_types::ThirtyTwoBytes */ - struct LDKUpdateFailMalformedHTLC *result; + LDKCOption_PaymentIdZ_Some, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * When we're in this state, this COption_PaymentIdZ contains nothing */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr; + LDKCOption_PaymentIdZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PaymentIdZ_Sentinel, +} LDKCOption_PaymentIdZ_Tag; + +typedef struct LDKCOption_PaymentIdZ { + LDKCOption_PaymentIdZ_Tag tag; + union { + struct { + struct LDKThirtyTwoBytes some; + }; + }; +} LDKCOption_PaymentIdZ; /** - * A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not */ -typedef struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ { +typedef enum LDKCOption_PaymentFailureReasonZ_Tag { /** - * The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason */ - union LDKCResult_UpdateFailMalformedHTLCDecodeErrorZPtr contents; + LDKCOption_PaymentFailureReasonZ_Some, /** - * Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + * When we're in this state, this COption_PaymentFailureReasonZ contains nothing */ - bool result_ok; -} LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ; + LDKCOption_PaymentFailureReasonZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PaymentFailureReasonZ_Sentinel, +} LDKCOption_PaymentFailureReasonZ_Tag; + +typedef struct LDKCOption_PaymentFailureReasonZ { + LDKCOption_PaymentFailureReasonZ_Tag tag; + union { + struct { + enum LDKPaymentFailureReason some; + }; + }; +} LDKCOption_PaymentFailureReasonZ; /** - * An [`update_fee`] message to be sent to or received from a peer - * - * [`update_fee`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#updating-fees-update_fee + * A descriptor used to sign for a commitment transaction's anchor output. */ -typedef struct MUST_USE_STRUCT LDKUpdateFee { +typedef struct MUST_USE_STRUCT LDKAnchorDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUpdateFee *inner; + LDKnativeAnchorDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUpdateFee; +} LDKAnchorDescriptor; + +/** + * Represents the different types of transactions, originating from LDK, to be bumped. + */ +typedef enum LDKBumpTransactionEvent_Tag { + /** + * Indicates that a channel featuring anchor outputs is to be closed by broadcasting the local + * commitment transaction. Since commitment transactions have a static feerate pre-agreed upon, + * they may need additional fees to be attached through a child transaction using the popular + * [Child-Pays-For-Parent](https://bitcoinops.org/en/topics/cpfp) fee bumping technique. This + * child transaction must include the anchor input described within `anchor_descriptor` along + * with additional inputs to meet the target feerate. Failure to meet the target feerate + * decreases the confirmation odds of the transaction package (which includes the commitment + * and child anchor transactions), possibly resulting in a loss of funds. Once the transaction + * is constructed, it must be fully signed for and broadcast by the consumer of the event + * along with the `commitment_tx` enclosed. Note that the `commitment_tx` must always be + * broadcast first, as the child anchor transaction depends on it. + * + * The consumer should be able to sign for any of the additional inputs included within the + * child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be + * re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature + * can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be + * provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the + * full witness required to spend. + * + * It is possible to receive more than one instance of this event if a valid child anchor + * transaction is never broadcast or is but not with a sufficient fee to be mined. Care should + * be taken by the consumer of the event to ensure any future iterations of the child anchor + * transaction adhere to the [Replace-By-Fee + * rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md) + * for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of + * these events is not user-controlled, users may ignore/drop the event if they are no longer + * able to commit external confirmed funds to the child anchor transaction. + * + * The set of `pending_htlcs` on the commitment transaction to be broadcast can be inspected to + * determine whether a significant portion of the channel's funds are allocated to HTLCs, + * enabling users to make their own decisions regarding the importance of the commitment + * transaction's confirmation. Note that this is not required, but simply exists as an option + * for users to override LDK's behavior. On commitments with no HTLCs (indicated by those with + * an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to + * be not urgent. + * + * [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner + * [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input + * [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness + */ + LDKBumpTransactionEvent_ChannelClose, + /** + * Indicates that a channel featuring anchor outputs has unilaterally closed on-chain by a + * holder commitment transaction and its HTLC(s) need to be resolved on-chain. With the + * zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC + * transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached + * for a timely confirmation within the chain. These additional inputs and/or outputs must be + * appended to the resulting HTLC transaction to meet the target feerate. Failure to meet the + * target feerate decreases the confirmation odds of the transaction, possibly resulting in a + * loss of funds. Once the transaction meets the target feerate, it must be signed for and + * broadcast by the consumer of the event. + * + * The consumer should be able to sign for any of the non-HTLC inputs added to the resulting + * HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived + * through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be + * computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be + * provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required + * to spend. + * + * It is possible to receive more than one instance of this event if a valid HTLC transaction + * is never broadcast or is but not with a sufficient fee to be mined. Care should be taken by + * the consumer of the event to ensure any future iterations of the HTLC transaction adhere to + * the [Replace-By-Fee + * rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md) + * for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of + * these events is not user-controlled, users may ignore/drop the event if either they are no + * longer able to commit external confirmed funds to the HTLC transaction or the fee committed + * to the HTLC transaction is greater in value than the HTLCs being claimed. + * + * [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner + * [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction + * [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness + */ + LDKBumpTransactionEvent_HTLCResolution, + /** + * Must be last for serialization purposes + */ + LDKBumpTransactionEvent_Sentinel, +} LDKBumpTransactionEvent_Tag; -/** - * The contents of CResult_UpdateFeeDecodeErrorZ - */ -typedef union LDKCResult_UpdateFeeDecodeErrorZPtr { +typedef struct LDKBumpTransactionEvent_LDKChannelClose_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The unique identifier for the claim of the anchor output in the commitment transaction. + * + * The identifier must map to the set of external UTXOs assigned to the claim, such that + * they can be reused when a new claim with the same identifier needs to be made, resulting + * in a fee-bumping attempt. */ - struct LDKUpdateFee *result; + struct LDKThirtyTwoBytes claim_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The target feerate that the transaction package, which consists of the commitment + * transaction and the to-be-crafted child anchor transaction, must meet. */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFeeDecodeErrorZPtr; - -/** - * A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UpdateFeeDecodeErrorZ { + uint32_t package_target_feerate_sat_per_1000_weight; /** - * The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The channel's commitment transaction to bump the fee of. This transaction should be + * broadcast along with the anchor transaction constructed as a result of consuming this + * event. */ - union LDKCResult_UpdateFeeDecodeErrorZPtr contents; + struct LDKTransaction commitment_tx; /** - * Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + * The absolute fee in satoshis of the commitment transaction. This can be used along the + * with weight of the commitment transaction to determine its feerate. */ - bool result_ok; -} LDKCResult_UpdateFeeDecodeErrorZ; - -/** - * The contents of CResult_UpdateFulfillHTLCDecodeErrorZ - */ -typedef union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr { + uint64_t commitment_tx_fee_satoshis; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The descriptor to sign the anchor input of the anchor transaction constructed as a + * result of consuming this event. */ - struct LDKUpdateFulfillHTLC *result; + struct LDKAnchorDescriptor anchor_descriptor; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The set of pending HTLCs on the commitment transaction that need to be resolved once the + * commitment transaction confirms. */ - struct LDKDecodeError *err; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr; + struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs; +} LDKBumpTransactionEvent_LDKChannelClose_Body; -/** - * A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ { +typedef struct LDKBumpTransactionEvent_LDKHTLCResolution_Body { /** - * The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The unique identifier for the claim of the HTLCs in the confirmed commitment + * transaction. + * + * The identifier must map to the set of external UTXOs assigned to the claim, such that + * they can be reused when a new claim with the same identifier needs to be made, resulting + * in a fee-bumping attempt. */ - union LDKCResult_UpdateFulfillHTLCDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes claim_id; /** - * Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + * The target feerate that the resulting HTLC transaction must meet. */ - bool result_ok; -} LDKCResult_UpdateFulfillHTLCDecodeErrorZ; - -/** - * The contents of CResult_UpdateAddHTLCDecodeErrorZ - */ -typedef union LDKCResult_UpdateAddHTLCDecodeErrorZPtr { + uint32_t target_feerate_sat_per_1000_weight; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably + * by the same transaction. */ - struct LDKUpdateAddHTLC *result; + struct LDKCVec_HTLCDescriptorZ htlc_descriptors; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The locktime required for the resulting HTLC transaction. */ - struct LDKDecodeError *err; -} LDKCResult_UpdateAddHTLCDecodeErrorZPtr; + uint32_t tx_lock_time; +} LDKBumpTransactionEvent_LDKHTLCResolution_Body; + +typedef struct MUST_USE_STRUCT LDKBumpTransactionEvent { + LDKBumpTransactionEvent_Tag tag; + union { + LDKBumpTransactionEvent_LDKChannelClose_Body channel_close; + LDKBumpTransactionEvent_LDKHTLCResolution_Body htlc_resolution; + }; +} LDKBumpTransactionEvent; /** - * A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An Event which you should probably take some action in response to. + * + * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use + * them directly as they don't round-trip exactly (for example FundingGenerationReady is never + * written as it makes no sense to respond to it after reconnecting to peers). */ -typedef struct LDKCResult_UpdateAddHTLCDecodeErrorZ { +typedef enum LDKEvent_Tag { /** - * The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Used to indicate that the client should generate a funding transaction with the given + * parameters and then call [`ChannelManager::funding_transaction_generated`]. + * Generated in [`ChannelManager`] message handling. + * Note that *all inputs* in the funding transaction must spend SegWit outputs or your + * counterparty can steal your funds! + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - union LDKCResult_UpdateAddHTLCDecodeErrorZPtr contents; + LDKEvent_FundingGenerationReady, /** - * Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + * Indicates that we've been offered a payment and it needs to be claimed via calling + * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. + * + * Note that if the preimage is not known, you should call + * [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] + * to free up resources for this HTLC and avoid network congestion. + * If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], + * or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be + * automatically failed. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentClaimable` events may be generated for the same payment. In such a case it is + * polite (and required in the lightning specification) to fail the payment the second time + * and give the sender their money back rather than accepting double payment. + * + * # Note + * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards + * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason */ - bool result_ok; -} LDKCResult_UpdateAddHTLCDecodeErrorZ; - - - -/** - * An onion message to be sent to or received from a peer. - * - */ -typedef struct MUST_USE_STRUCT LDKOnionMessage { + LDKEvent_PaymentClaimable, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Indicates a payment has been claimed and we've received money! + * + * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response + * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a + * [`ChannelManager::claim_funds`] call you may see this event without a corresponding + * [`Event::PaymentClaimable`] event. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentClaimable` events may be generated for the same payment. If you then call + * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get + * multiple `PaymentClaimed` events. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ - LDKnativeOnionMessage *inner; + LDKEvent_PaymentClaimed, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target + * and we got back the payment preimage for it). + * + * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` + * event. In this situation, you SHOULD treat this payment as having succeeded. */ - bool is_owned; -} LDKOnionMessage; - -/** - * The contents of CResult_OnionMessageDecodeErrorZ - */ -typedef union LDKCResult_OnionMessageDecodeErrorZPtr { + LDKEvent_PaymentSent, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events + * provide failure information for each path attempt in the payment, including retries. + * + * This event is provided once there are no further pending HTLCs for the payment and the + * payment is no longer retryable, due either to the [`Retry`] provided or + * [`ChannelManager::abandon_payment`] having been called for the corresponding payment. + * + * [`Retry`]: crate::ln::channelmanager::Retry + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - struct LDKOnionMessage *result; + LDKEvent_PaymentFailed, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that a path for an outbound payment was successful. + * + * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See + * [`Event::PaymentSent`] for obtaining the payment preimage. */ - struct LDKDecodeError *err; -} LDKCResult_OnionMessageDecodeErrorZPtr; - -/** - * A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_OnionMessageDecodeErrorZ { + LDKEvent_PaymentPathSuccessful, /** - * The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to + * handle the HTLC. + * + * Note that this does *not* indicate that all paths for an MPP payment have failed, see + * [`Event::PaymentFailed`]. + * + * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have + * been exhausted. + * + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - union LDKCResult_OnionMessageDecodeErrorZPtr contents; + LDKEvent_PaymentPathFailed, /** - * Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. */ - bool result_ok; -} LDKCResult_OnionMessageDecodeErrorZ; - - - -/** - * A [`ping`] message to be sent to or received from a peer. - * - * [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages - */ -typedef struct MUST_USE_STRUCT LDKPing { + LDKEvent_ProbeSuccessful, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Indicates that a probe payment we sent failed at an intermediary node on the path. */ - LDKnativePing *inner; + LDKEvent_ProbeFailed, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at + * a time in the future. + * + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards */ - bool is_owned; -} LDKPing; - -/** - * The contents of CResult_PingDecodeErrorZ - */ -typedef union LDKCResult_PingDecodeErrorZPtr { + LDKEvent_PendingHTLCsForwardable, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if + * you've encoded an intercept scid in the receiver's invoice route hints using + * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. + * + * [`ChannelManager::forward_intercepted_htlc`] or + * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See + * their docs for more information. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs + * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc */ - struct LDKPing *result; + LDKEvent_HTLCIntercepted, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that an output which you should know how to spend was confirmed on chain + * and is now spendable. + * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + * counterparty spending them due to some kind of timeout. Thus, you need to store them + * somewhere and spend them when you create on-chain transactions. */ - struct LDKDecodeError *err; -} LDKCResult_PingDecodeErrorZPtr; - -/** - * A CResult_PingDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PingDecodeErrorZ { + LDKEvent_SpendableOutputs, /** - * The contents of this CResult_PingDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * This event is generated when a payment has been successfully forwarded through us and a + * forwarding fee earned. */ - union LDKCResult_PingDecodeErrorZPtr contents; + LDKEvent_PaymentForwarded, /** - * Whether this CResult_PingDecodeErrorZ represents a success state. + * Used to indicate that a channel with the given `channel_id` is being opened and pending + * confirmation on-chain. + * + * This event is emitted when the funding transaction has been signed and is broadcast to the + * network. For 0conf channels it will be immediately followed by the corresponding + * [`Event::ChannelReady`] event. */ - bool result_ok; -} LDKCResult_PingDecodeErrorZ; - - - -/** - * A [`pong`] message to be sent to or received from a peer. - * - * [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages - */ -typedef struct MUST_USE_STRUCT LDKPong { + LDKEvent_ChannelPending, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Used to indicate that a channel with the given `channel_id` is ready to + * be used. This event is emitted either when the funding transaction has been confirmed + * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel + * establishment. */ - LDKnativePong *inner; + LDKEvent_ChannelReady, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Used to indicate that a previously opened channel with the given `channel_id` is in the + * process of closure. */ - bool is_owned; -} LDKPong; - -/** - * The contents of CResult_PongDecodeErrorZ - */ -typedef union LDKCResult_PongDecodeErrorZPtr { + LDKEvent_ChannelClosed, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate to the user that they can abandon the funding transaction and recycle the + * inputs for another purpose. */ - struct LDKPong *result; + LDKEvent_DiscardFunding, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates a request to open a new channel by a peer. + * + * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the + * request, call [`ChannelManager::force_close_without_broadcasting_txn`]. + * + * The event is only triggered when a new open channel request is received and the + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - struct LDKDecodeError *err; -} LDKCResult_PongDecodeErrorZPtr; - -/** - * A CResult_PongDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PongDecodeErrorZ { + LDKEvent_OpenChannelRequest, /** - * The contents of this CResult_PongDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Indicates that the HTLC was accepted, but could not be processed when or after attempting to + * forward it. + * + * Some scenarios where this event may be sent include: + * * Insufficient capacity in the outbound channel + * * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes + * * When an unknown SCID is requested for forwarding a payment. + * * Expected MPP amount has already been reached + * * The HTLC has timed out + * + * This event, however, does not get generated if an HTLC fails to meet the forwarding + * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). */ - union LDKCResult_PongDecodeErrorZPtr contents; + LDKEvent_HTLCHandlingFailed, /** - * Whether this CResult_PongDecodeErrorZ represents a success state. + * Indicates that a transaction originating from LDK needs to have its fee bumped. This event + * requires confirmed external funds to be readily available to spend. + * + * LDK does not currently generate this event unless the + * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. + * It is limited to the scope of channels with anchor outputs. + * + * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx */ - bool result_ok; -} LDKCResult_PongDecodeErrorZ; - -/** - * The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ - */ -typedef union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + LDKEvent_BumpTransaction, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Must be last for serialization purposes */ - struct LDKUnsignedChannelAnnouncement *result; + LDKEvent_Sentinel, +} LDKEvent_Tag; + +typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The random channel_id we picked which you'll need to pass into + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr; - -/** - * A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ { + struct LDKThirtyTwoBytes temporary_channel_id; /** - * The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The counterparty's node_id, which you'll need to pass back into + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - union LDKCResult_UnsignedChannelAnnouncementDecodeErrorZPtr contents; + struct LDKPublicKey counterparty_node_id; /** - * Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + * The value, in satoshis, that the output should have. */ - bool result_ok; -} LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ; - -/** - * The contents of CResult_ChannelAnnouncementDecodeErrorZ - */ -typedef union LDKCResult_ChannelAnnouncementDecodeErrorZPtr { + uint64_t channel_value_satoshis; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The script which should be used in the transaction output. */ - struct LDKChannelAnnouncement *result; + struct LDKCVec_u8Z output_script; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a + * random value for an inbound channel. This may be zero for objects serialized with LDK + * versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel */ - struct LDKDecodeError *err; -} LDKCResult_ChannelAnnouncementDecodeErrorZPtr; + struct LDKU128 user_channel_id; +} LDKEvent_LDKFundingGenerationReady_Body; -/** - * A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelAnnouncementDecodeErrorZ { +typedef struct LDKEvent_LDKPaymentClaimable_Body { /** - * The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node that will receive the payment after it has been claimed. + * This is useful to identify payments received via [phantom nodes]. + * This field will always be filled in when the event was generated by LDK versions + * 0.0.113 and above. + * + * [phantom nodes]: crate::sign::PhantomKeysManager + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - union LDKCResult_ChannelAnnouncementDecodeErrorZPtr contents; + struct LDKPublicKey receiver_node_id; /** - * Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will + * not stop you from registering duplicate payment hashes for inbound payments. */ - bool result_ok; -} LDKCResult_ChannelAnnouncementDecodeErrorZ; - -/** - * The contents of CResult_UnsignedChannelUpdateDecodeErrorZ - */ -typedef union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr { + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The fields in the onion which were received with each HTLC. Only fields which were + * identical in each HTLC involved in the payment will be included here. + * + * Payments received on LDK versions prior to 0.0.115 will have this field unset. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKUnsignedChannelUpdate *result; + struct LDKRecipientOnionFields onion_fields; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The value, in thousandths of a satoshi, that this payment is claimable for. May be greater + * than the invoice amount. + * + * May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set + * and the previous hop took an extra fee. + * + * # Note + * If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this + * field, you may lose money! + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr; - -/** - * A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ { + uint64_t amount_msat; /** - * The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee + * taken by our channel counterparty. + * + * Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ - union LDKCResult_UnsignedChannelUpdateDecodeErrorZPtr contents; + uint64_t counterparty_skimmed_fee_msat; /** - * Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + * Information for claiming this received payment, based on whether the purpose of the + * payment is to pay an invoice or to send a spontaneous payment. */ - bool result_ok; -} LDKCResult_UnsignedChannelUpdateDecodeErrorZ; - -/** - * The contents of CResult_ChannelUpdateDecodeErrorZ - */ -typedef union LDKCResult_ChannelUpdateDecodeErrorZPtr { + struct LDKPaymentPurpose purpose; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The `channel_id` indicating over which channel we received the payment. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKChannelUpdate *result; + struct LDKThirtyTwoBytes via_channel_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The `user_channel_id` indicating over which channel we received the payment. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelUpdateDecodeErrorZPtr; + struct LDKCOption_u128Z via_user_channel_id; + /** + * The block height at which this payment will be failed back and will no longer be + * eligible for claiming. + * + * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to + * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + */ + struct LDKCOption_u32Z claim_deadline; +} LDKEvent_LDKPaymentClaimable_Body; -/** - * A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelUpdateDecodeErrorZ { +typedef struct LDKEvent_LDKPaymentClaimed_Body { /** - * The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node that received the payment. + * This is useful to identify payments which were received via [phantom nodes]. + * This field will always be filled in when the event was generated by LDK versions + * 0.0.113 and above. + * + * [phantom nodes]: crate::sign::PhantomKeysManager + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - union LDKCResult_ChannelUpdateDecodeErrorZPtr contents; + struct LDKPublicKey receiver_node_id; /** - * Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + * The payment hash of the claimed payment. Note that LDK will not stop you from + * registering duplicate payment hashes for inbound payments. */ - bool result_ok; -} LDKCResult_ChannelUpdateDecodeErrorZ; - -/** - * The contents of CResult_ErrorMessageDecodeErrorZ - */ -typedef union LDKCResult_ErrorMessageDecodeErrorZPtr { + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The value, in thousandths of a satoshi, that this payment is for. May be greater than the + * invoice amount. */ - struct LDKErrorMessage *result; + uint64_t amount_msat; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a + * spontaneous payment. */ - struct LDKDecodeError *err; -} LDKCResult_ErrorMessageDecodeErrorZPtr; + struct LDKPaymentPurpose purpose; +} LDKEvent_LDKPaymentClaimed_Body; -/** - * A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ErrorMessageDecodeErrorZ { +typedef struct LDKEvent_LDKPaymentSent_Body { /** - * The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - union LDKCResult_ErrorMessageDecodeErrorZPtr contents; + struct LDKCOption_PaymentIdZ payment_id; /** - * Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + * 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 + * store it somehow! */ - bool result_ok; -} LDKCResult_ErrorMessageDecodeErrorZ; - -/** - * The contents of CResult_WarningMessageDecodeErrorZ - */ -typedef union LDKCResult_WarningMessageDecodeErrorZPtr { + struct LDKThirtyTwoBytes payment_preimage; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - struct LDKWarningMessage *result; + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * 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 */ - struct LDKDecodeError *err; -} LDKCResult_WarningMessageDecodeErrorZPtr; + struct LDKCOption_u64Z fee_paid_msat; +} LDKEvent_LDKPaymentSent_Body; -/** - * A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_WarningMessageDecodeErrorZ { +typedef struct LDKEvent_LDKPaymentFailed_Body { /** - * The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - union LDKCResult_WarningMessageDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes payment_id; /** - * Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - bool result_ok; -} LDKCResult_WarningMessageDecodeErrorZ; - -/** - * The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ - */ -typedef union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The reason the payment failed. This is only `None` for events generated or serialized + * by versions prior to 0.0.115. */ - struct LDKUnsignedNodeAnnouncement *result; + struct LDKCOption_PaymentFailureReasonZ reason; +} LDKEvent_LDKPaymentFailed_Body; + +typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - struct LDKDecodeError *err; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr; - -/** - * A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ { + struct LDKThirtyTwoBytes payment_id; /** - * The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * This will be `Some` for all payments which completed on LDK 0.0.104 or later. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - union LDKCResult_UnsignedNodeAnnouncementDecodeErrorZPtr contents; + struct LDKCOption_PaymentHashZ payment_hash; /** - * Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + * The payment path that was successful. + * + * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. */ - bool result_ok; -} LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ; + struct LDKPath path; +} LDKEvent_LDKPaymentPathSuccessful_Body; -/** - * The contents of CResult_NodeAnnouncementDecodeErrorZ - */ -typedef union LDKCResult_NodeAnnouncementDecodeErrorZPtr { +typedef struct LDKEvent_LDKPaymentPathFailed_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * This will be `Some` for all payment paths which failed on LDK 0.0.103 or later. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - struct LDKNodeAnnouncement *result; + struct LDKCOption_PaymentIdZ payment_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - struct LDKDecodeError *err; -} LDKCResult_NodeAnnouncementDecodeErrorZPtr; - -/** - * A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NodeAnnouncementDecodeErrorZ { + struct LDKThirtyTwoBytes payment_hash; /** - * The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Indicates the payment was rejected for some reason by the recipient. This implies that + * the payment has failed, not just the route in question. If this is not set, the payment may + * be retried via a different route. */ - union LDKCResult_NodeAnnouncementDecodeErrorZPtr contents; + bool payment_failed_permanently; /** - * Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + * Extra error details based on the failure type. May contain an update that needs to be + * applied to the [`NetworkGraph`]. + * + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ - bool result_ok; -} LDKCResult_NodeAnnouncementDecodeErrorZ; - -/** - * The contents of CResult_QueryShortChannelIdsDecodeErrorZ - */ -typedef union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr { + struct LDKPathFailure failure; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The payment path that failed. */ - struct LDKQueryShortChannelIds *result; + struct LDKPath path; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The channel responsible for the failed payment path. + * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. + * + * If this is `Some`, then the corresponding channel should be avoided when the payment is + * retried. May be `None` for older [`Event`] serializations. */ - struct LDKDecodeError *err; -} LDKCResult_QueryShortChannelIdsDecodeErrorZPtr; + struct LDKCOption_u64Z short_channel_id; +} LDKEvent_LDKPaymentPathFailed_Body; -/** - * A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_QueryShortChannelIdsDecodeErrorZ { - /** - * The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_QueryShortChannelIdsDecodeErrorZPtr contents; +typedef struct LDKEvent_LDKProbeSuccessful_Body { /** - * Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + * The id returned by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - bool result_ok; -} LDKCResult_QueryShortChannelIdsDecodeErrorZ; - - - -/** - * A [`reply_short_channel_ids_end`] message is sent as a reply to a - * message. The query recipient makes a best - * effort to respond based on their local network view which may not be - * a perfect view of the network. - * - * [`reply_short_channel_ids_end`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages - */ -typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd { + struct LDKThirtyTwoBytes payment_id; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The hash generated by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - LDKnativeReplyShortChannelIdsEnd *inner; + struct LDKThirtyTwoBytes payment_hash; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The payment path that was successful. */ - bool is_owned; -} LDKReplyShortChannelIdsEnd; + struct LDKPath path; +} LDKEvent_LDKProbeSuccessful_Body; -/** - * The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ - */ -typedef union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +typedef struct LDKEvent_LDKProbeFailed_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The id returned by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKReplyShortChannelIdsEnd *result; + struct LDKThirtyTwoBytes payment_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The hash generated by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKDecodeError *err; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr; - -/** - * A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ { + struct LDKThirtyTwoBytes payment_hash; /** - * The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The payment path that failed. */ - union LDKCResult_ReplyShortChannelIdsEndDecodeErrorZPtr contents; + struct LDKPath path; /** - * Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + * The channel responsible for the failed probe. + * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. */ - bool result_ok; -} LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ; + struct LDKCOption_u64Z short_channel_id; +} LDKEvent_LDKProbeFailed_Body; -/** - * The contents of CResult_QueryChannelRangeDecodeErrorZ - */ -typedef union LDKCResult_QueryChannelRangeDecodeErrorZPtr { +typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The minimum amount of time that should be waited prior to calling + * process_pending_htlc_forwards. To increase the effort required to correlate payments, + * you should wait a random amount of time in roughly the range (now + time_forwardable, + * now + 5*time_forwardable). */ - struct LDKQueryChannelRange *result; + uint64_t time_forwardable; +} LDKEvent_LDKPendingHTLCsForwardable_Body; + +typedef struct LDKEvent_LDKHTLCIntercepted_Body { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An id to help LDK identify which HTLC is being forwarded or failed. */ - struct LDKDecodeError *err; -} LDKCResult_QueryChannelRangeDecodeErrorZPtr; - -/** - * A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_QueryChannelRangeDecodeErrorZ { + struct LDKThirtyTwoBytes intercept_id; /** - * The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The fake scid that was programmed as the next hop's scid, generated using + * [`ChannelManager::get_intercept_scid`]. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid */ - union LDKCResult_QueryChannelRangeDecodeErrorZPtr contents; + uint64_t requested_next_hop_scid; /** - * Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + * The payment hash used for this HTLC. */ - bool result_ok; -} LDKCResult_QueryChannelRangeDecodeErrorZ; - -/** - * The contents of CResult_ReplyChannelRangeDecodeErrorZ - */ -typedef union LDKCResult_ReplyChannelRangeDecodeErrorZPtr { + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * How many msats were received on the inbound edge of this HTLC. */ - struct LDKReplyChannelRange *result; + uint64_t inbound_amount_msat; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * How many msats the payer intended to route to the next node. Depending on the reason you are + * intercepting this payment, you might take a fee by forwarding less than this amount. + * Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116. + * + * Note that LDK will NOT check that expected fees were factored into this value. You MUST + * check that whatever fee you want has been included here or subtract it as required. Further, + * LDK will not stop you from forwarding more than you received. */ - struct LDKDecodeError *err; -} LDKCResult_ReplyChannelRangeDecodeErrorZPtr; + uint64_t expected_outbound_amount_msat; +} LDKEvent_LDKHTLCIntercepted_Body; -/** - * A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { +typedef struct LDKEvent_LDKSpendableOutputs_Body { /** - * The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The outputs which you should store as spendable by you. */ - union LDKCResult_ReplyChannelRangeDecodeErrorZPtr contents; + struct LDKCVec_SpendableOutputDescriptorZ outputs; +} LDKEvent_LDKSpendableOutputs_Body; + +typedef struct LDKEvent_LDKPaymentForwarded_Body { /** - * Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + * The incoming channel between the previous node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - bool result_ok; -} LDKCResult_ReplyChannelRangeDecodeErrorZ; - -/** - * The contents of CResult_GossipTimestampFilterDecodeErrorZ - */ -typedef union LDKCResult_GossipTimestampFilterDecodeErrorZPtr { + struct LDKThirtyTwoBytes prev_channel_id; /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The outgoing channel between the next node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKGossipTimestampFilter *result; + struct LDKThirtyTwoBytes next_channel_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The fee, in milli-satoshis, which was earned as a result of the payment. + * + * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC + * was pending, the amount the next hop claimed will have been rounded down to the nearest + * whole satoshi. Thus, the fee calculated here may be higher than expected as we still + * claimed the full value in millisatoshis from the source. In this case, + * `claim_from_onchain_tx` will be set. + * + * If the channel which sent us the payment has been force-closed, we will claim the funds + * via an on-chain transaction. In that case we do not yet know the on-chain transaction + * fees which we will spend and will instead set this to `None`. It is possible duplicate + * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + * `None`. */ - struct LDKDecodeError *err; -} LDKCResult_GossipTimestampFilterDecodeErrorZPtr; - -/** - * A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { + struct LDKCOption_u64Z fee_earned_msat; /** - * The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain + * transaction. */ - union LDKCResult_GossipTimestampFilterDecodeErrorZPtr contents; + bool claim_from_onchain_tx; /** - * Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + * The final amount forwarded, in milli-satoshis, after the fee is deducted. + * + * The caveat described above the `fee_earned_msat` field applies here as well. */ - bool result_ok; -} LDKCResult_GossipTimestampFilterDecodeErrorZ; + struct LDKCOption_u64Z outbound_amount_forwarded_msat; +} LDKEvent_LDKPaymentForwarded_Body; -/** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_PhantomRouteHintsZ { +typedef struct LDKEvent_LDKChannelPending_Body { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The `channel_id` of the channel that is pending confirmation. */ - struct LDKPhantomRouteHints *data; + struct LDKThirtyTwoBytes channel_id; /** - * The number of elements pointed to by `data`. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - uintptr_t datalen; -} LDKCVec_PhantomRouteHintsZ; - -/** - * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] - * may occur. - */ -typedef enum LDKSignOrCreationError_Tag { + struct LDKU128 user_channel_id; /** - * An error occurred during signing + * The `temporary_channel_id` this channel used to be known by during channel establishment. + * + * Will be `None` for channels created prior to LDK version 0.0.115. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKSignOrCreationError_SignError, + struct LDKThirtyTwoBytes former_temporary_channel_id; /** - * An error occurred while building the transaction + * The `node_id` of the channel counterparty. */ - LDKSignOrCreationError_CreationError, + struct LDKPublicKey counterparty_node_id; /** - * Must be last for serialization purposes + * The outpoint of the channel's funding transaction. */ - LDKSignOrCreationError_Sentinel, -} LDKSignOrCreationError_Tag; - -typedef struct MUST_USE_STRUCT LDKSignOrCreationError { - LDKSignOrCreationError_Tag tag; - union { - struct { - enum LDKCreationError creation_error; - }; - }; -} LDKSignOrCreationError; + struct LDKOutPoint funding_txo; +} LDKEvent_LDKChannelPending_Body; -/** - * The contents of CResult_InvoiceSignOrCreationErrorZ - */ -typedef union LDKCResult_InvoiceSignOrCreationErrorZPtr { +typedef struct LDKEvent_LDKChannelReady_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The `channel_id` of the channel that is ready. */ - struct LDKInvoice *result; + struct LDKThirtyTwoBytes channel_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - struct LDKSignOrCreationError *err; -} LDKCResult_InvoiceSignOrCreationErrorZPtr; - -/** - * A CResult_InvoiceSignOrCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { + struct LDKU128 user_channel_id; /** - * The contents of this CResult_InvoiceSignOrCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The `node_id` of the channel counterparty. */ - union LDKCResult_InvoiceSignOrCreationErrorZPtr contents; + struct LDKPublicKey counterparty_node_id; /** - * Whether this CResult_InvoiceSignOrCreationErrorZ represents a success state. + * The features that this channel will operate with. */ - bool result_ok; -} LDKCResult_InvoiceSignOrCreationErrorZ; - - + struct LDKChannelTypeFeatures channel_type; +} LDKEvent_LDKChannelReady_Body; -/** - * A simple future which can complete once, and calls some callback(s) when it does so. - * - * Clones can be made and all futures cloned from the same source will complete at the same time. - */ -typedef struct MUST_USE_STRUCT LDKFuture { +typedef struct LDKEvent_LDKChannelClosed_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The `channel_id` of the channel which has been closed. Note that on-chain transactions + * resolving the channel are likely still awaiting confirmation. */ - LDKnativeFuture *inner; + struct LDKThirtyTwoBytes channel_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKFuture; - -/** - * A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_FutureZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for inbound channels. + * This may be zero for inbound channels serialized prior to 0.0.113 and will always be + * zero for objects serialized with LDK versions prior to 0.0.102. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - struct LDKFuture *data; + struct LDKU128 user_channel_id; /** - * The number of elements pointed to by `data`. + * The reason the channel was closed. */ - uintptr_t datalen; -} LDKCVec_FutureZ; - - + struct LDKClosureReason reason; +} LDKEvent_LDKChannelClosed_Body; -/** - * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. - * - * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction - * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * [`Confirm::transactions_confirmed`]. - * - * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and - * may have been spent there. See [`Filter::register_output`] for details. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected - */ -typedef struct MUST_USE_STRUCT LDKWatchedOutput { +typedef struct LDKEvent_LDKDiscardFunding_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The channel_id of the channel which has been closed. */ - LDKnativeWatchedOutput *inner; + struct LDKThirtyTwoBytes channel_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The full transaction received from the user */ - bool is_owned; -} LDKWatchedOutput; + struct LDKTransaction transaction; +} LDKEvent_LDKDiscardFunding_Body; -/** - * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to - * channels. - * - * This is useful in order to have a [`Watch`] implementation convey to a chain source which - * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in - * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If - * receiving full blocks from a chain source, any further filtering is unnecessary. - * - * After an output has been registered, subsequent block retrievals from the chain source must not - * exclude any transactions matching the new criteria nor any in-block descendants of such - * transactions. - * - * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` - * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any [`Watch`] - * invocation that has called the `Filter` must return [`InProgress`]. - * - * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress - * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki - * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki - */ -typedef struct LDKFilter { +typedef struct LDKEvent_LDKOpenChannelRequest_Body { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The temporary channel ID of the channel requested to be opened. + * + * When responding to the request, the `temporary_channel_id` should be passed + * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, + * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ - void *this_arg; + struct LDKThirtyTwoBytes temporary_channel_id; /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. + * The node_id of the counterparty requesting to open the channel. + * + * When responding to the request, the `counterparty_node_id` should be passed + * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to + * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the + * request. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ - void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + struct LDKPublicKey counterparty_node_id; /** - * Registers interest in spends of a transaction output. - * - * Note that this method might be called during processing of a new block. You therefore need - * to ensure that also dependent output spents within an already connected block are correctly - * handled, e.g., by re-scanning the block in question whenever new outputs have been - * registered mid-processing. + * The channel value of the requested channel. */ - void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + uint64_t funding_satoshis; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Our starting balance in the channel if the request is accepted, in milli-satoshi. */ - void (*free)(void *this_arg); -} LDKFilter; - -/** - * An enum which can either contain a crate::lightning::chain::Filter or not - */ -typedef enum LDKCOption_FilterZ_Tag { + uint64_t push_msat; /** - * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter + * The features that this channel will operate with. If you reject the channel, a + * well-behaved counterparty may automatically re-attempt the channel with a new set of + * feature flags. + * + * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.106. + * + * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.107. Channels setting this type also need to get manually accepted via + * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], + * or will be rejected otherwise. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - LDKCOption_FilterZ_Some, + struct LDKChannelTypeFeatures channel_type; +} LDKEvent_LDKOpenChannelRequest_Body; + +typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { /** - * When we're in this state, this COption_FilterZ contains nothing + * The channel over which the HTLC was received. */ - LDKCOption_FilterZ_None, + struct LDKThirtyTwoBytes prev_channel_id; /** - * Must be last for serialization purposes + * Destination of the HTLC that failed to be processed. */ - LDKCOption_FilterZ_Sentinel, -} LDKCOption_FilterZ_Tag; + struct LDKHTLCDestination failed_next_destination; +} LDKEvent_LDKHTLCHandlingFailed_Body; -typedef struct LDKCOption_FilterZ { - LDKCOption_FilterZ_Tag tag; +typedef struct MUST_USE_STRUCT LDKEvent { + LDKEvent_Tag tag; union { + LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKPaymentClaimable_Body payment_claimable; + LDKEvent_LDKPaymentClaimed_Body payment_claimed; + LDKEvent_LDKPaymentSent_Body payment_sent; + LDKEvent_LDKPaymentFailed_Body payment_failed; + LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; + LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; + LDKEvent_LDKProbeSuccessful_Body probe_successful; + LDKEvent_LDKProbeFailed_Body probe_failed; + LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; + LDKEvent_LDKHTLCIntercepted_Body htlc_intercepted; + LDKEvent_LDKSpendableOutputs_Body spendable_outputs; + LDKEvent_LDKPaymentForwarded_Body payment_forwarded; + LDKEvent_LDKChannelPending_Body channel_pending; + LDKEvent_LDKChannelReady_Body channel_ready; + LDKEvent_LDKChannelClosed_Body channel_closed; + LDKEvent_LDKDiscardFunding_Body discard_funding; + LDKEvent_LDKOpenChannelRequest_Body open_channel_request; + LDKEvent_LDKHTLCHandlingFailed_Body htlc_handling_failed; struct { - struct LDKFilter some; + struct LDKBumpTransactionEvent bump_transaction; }; }; -} LDKCOption_FilterZ; - - +} LDKEvent; /** - * A read-only reference to a current ChannelMonitor. - * - * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is - * released. + * An enum which can either contain a crate::lightning::events::Event or not */ -typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { +typedef enum LDKCOption_EventZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_EventZ contains a crate::lightning::events::Event */ - LDKnativeLockedChannelMonitor *inner; + LDKCOption_EventZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_EventZ contains nothing */ - bool is_owned; -} LDKLockedChannelMonitor; + LDKCOption_EventZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_EventZ_Sentinel, +} LDKCOption_EventZ_Tag; + +typedef struct LDKCOption_EventZ { + LDKCOption_EventZ_Tag tag; + union { + struct { + struct LDKEvent some; + }; + }; +} LDKCOption_EventZ; /** - * The contents of CResult_LockedChannelMonitorNoneZ + * The contents of CResult_COption_EventZDecodeErrorZ */ -typedef union LDKCResult_LockedChannelMonitorNoneZPtr { +typedef union LDKCResult_COption_EventZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKLockedChannelMonitor *result; + struct LDKCOption_EventZ *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_LockedChannelMonitorNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_COption_EventZDecodeErrorZPtr; /** - * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, - * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_LockedChannelMonitorNoneZ { +typedef struct LDKCResult_COption_EventZDecodeErrorZ { /** - * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_LockedChannelMonitorNoneZPtr contents; + union LDKCResult_COption_EventZDecodeErrorZPtr contents; /** - * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + * Whether this CResult_COption_EventZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_LockedChannelMonitorNoneZ; +} LDKCResult_COption_EventZDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_OutPointZ { +typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKOutPoint *data; + struct LDKC2Tuple_BlockHashChannelMonitorZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_OutPointZ; - +} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; +/** + * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ + */ +typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKIOError *err; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; /** - * An opaque identifier describing a specific [`Persist`] method call. + * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { +typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeMonitorUpdateId *inner; + union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. */ - bool is_owned; -} LDKMonitorUpdateId; + bool result_ok; +} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. - * This corresponds to std::vector in C++ + * Sub-errors which don't have specific information in them use this type. */ -typedef struct LDKCVec_MonitorUpdateIdZ { +typedef struct LDKError { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here */ - struct LDKMonitorUpdateId *data; + uint8_t _dummy; +} LDKError; + +/** + * Errors that indicate what is wrong with the invoice. They have some granularity for debug + * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. + */ +typedef enum LDKBolt11ParseError_Tag { + LDKBolt11ParseError_Bech32Error, + LDKBolt11ParseError_ParseAmountError, + LDKBolt11ParseError_MalformedSignature, + LDKBolt11ParseError_BadPrefix, + LDKBolt11ParseError_UnknownCurrency, + LDKBolt11ParseError_UnknownSiPrefix, + LDKBolt11ParseError_MalformedHRP, + LDKBolt11ParseError_TooShortDataPart, + LDKBolt11ParseError_UnexpectedEndOfTaggedFields, + LDKBolt11ParseError_DescriptionDecodeError, + LDKBolt11ParseError_PaddingError, + LDKBolt11ParseError_IntegerOverflowError, + LDKBolt11ParseError_InvalidSegWitProgramLength, + LDKBolt11ParseError_InvalidPubKeyHashLength, + LDKBolt11ParseError_InvalidScriptHashLength, + LDKBolt11ParseError_InvalidRecoveryId, + LDKBolt11ParseError_InvalidSliceLength, /** - * The number of elements pointed to by `data`. + * Not an error, but used internally to signal that a part of the invoice should be ignored + * according to BOLT11 */ - uintptr_t datalen; -} LDKCVec_MonitorUpdateIdZ; + LDKBolt11ParseError_Skip, + /** + * Must be last for serialization purposes + */ + LDKBolt11ParseError_Sentinel, +} LDKBolt11ParseError_Tag; + +typedef struct MUST_USE_STRUCT LDKBolt11ParseError { + LDKBolt11ParseError_Tag tag; + union { + struct { + struct LDKBech32Error bech32_error; + }; + struct { + struct LDKError parse_amount_error; + }; + struct { + enum LDKSecp256k1Error malformed_signature; + }; + struct { + struct LDKError description_decode_error; + }; + struct { + struct LDKStr invalid_slice_length; + }; + }; +} LDKBolt11ParseError; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_SiPrefixBolt11ParseErrorZ */ -typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { +typedef union LDKCResult_SiPrefixBolt11ParseErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint a; + enum LDKSiPrefix *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_MonitorUpdateIdZ b; -} LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ; + struct LDKBolt11ParseError *err; +} LDKCResult_SiPrefixBolt11ParseErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_SiPrefixBolt11ParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::Bolt11ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +typedef struct LDKCResult_SiPrefixBolt11ParseErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_SiPrefixBolt11ParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; + union LDKCResult_SiPrefixBolt11ParseErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; + bool result_ok; +} LDKCResult_SiPrefixBolt11ParseErrorZ; /** - * All-encompassing standard error type that processing can return + * Indicates that something went wrong while parsing or validating the invoice. Parsing errors + * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors + * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. */ -typedef enum LDKGraphSyncError_Tag { +typedef enum LDKParseOrSemanticError_Tag { /** - * Error trying to read the update data, typically due to an erroneous data length indication - * that is greater than the actual amount of data provided + * The invoice couldn't be decoded */ - LDKGraphSyncError_DecodeError, + LDKParseOrSemanticError_ParseError, /** - * Error applying the patch to the network graph, usually the result of updates that are too - * old or missing prerequisite data to the application of updates out of order + * The invoice could be decoded but violates the BOLT11 standard */ - LDKGraphSyncError_LightningError, + LDKParseOrSemanticError_SemanticError, /** * Must be last for serialization purposes */ - LDKGraphSyncError_Sentinel, -} LDKGraphSyncError_Tag; + LDKParseOrSemanticError_Sentinel, +} LDKParseOrSemanticError_Tag; -typedef struct MUST_USE_STRUCT LDKGraphSyncError { - LDKGraphSyncError_Tag tag; +typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { + LDKParseOrSemanticError_Tag tag; union { struct { - struct LDKDecodeError decode_error; + struct LDKBolt11ParseError parse_error; }; struct { - struct LDKLightningError lightning_error; + enum LDKBolt11SemanticError semantic_error; }; }; -} LDKGraphSyncError; +} LDKParseOrSemanticError; /** - * The contents of CResult_u32GraphSyncErrorZ + * The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ */ -typedef union LDKCResult_u32GraphSyncErrorZPtr { +typedef union LDKCResult_Bolt11InvoiceParseOrSemanticErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - uint32_t *result; + struct LDKBolt11Invoice *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKGraphSyncError *err; -} LDKCResult_u32GraphSyncErrorZPtr; + struct LDKParseOrSemanticError *err; +} LDKCResult_Bolt11InvoiceParseOrSemanticErrorZPtr; /** - * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, - * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. + * A CResult_Bolt11InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_u32GraphSyncErrorZ { +typedef struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ { /** - * The contents of this CResult_u32GraphSyncErrorZ, accessible via either + * The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_u32GraphSyncErrorZPtr contents; + union LDKCResult_Bolt11InvoiceParseOrSemanticErrorZPtr contents; /** - * Whether this CResult_u32GraphSyncErrorZ represents a success state. + * Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. */ bool result_ok; -} LDKCResult_u32GraphSyncErrorZ; +} LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ; /** - * Lightning TLV uses a custom variable-length integer called `BigSize`. It is similar to Bitcoin's - * variable-length integers except that it is serialized in big-endian instead of little-endian. + * Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be + * invalid. * - * Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be - * encoded in several different ways, which we must check for at deserialization-time. Thus, if - * you're looking for an example of a variable-length integer to use for your own project, move - * along, this is a rather poor design. + * # Invariants + * The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice`]. */ -typedef struct MUST_USE_STRUCT LDKBigSize { +typedef struct MUST_USE_STRUCT LDKSignedRawBolt11Invoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBigSize *inner; + LDKnativeSignedRawBolt11Invoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBigSize; +} LDKSignedRawBolt11Invoice; /** - * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. + * The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ */ -typedef struct LDKPersister { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { /** - * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); + struct LDKSignedRawBolt11Invoice *result; /** - * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); + struct LDKBolt11ParseError *err; +} LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr; + +/** + * A CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SignedRawBolt11Invoice on success and a crate::lightning_invoice::Bolt11ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { /** - * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. + * The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKWriteableScore *NONNULL_PTR scorer); + union LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKPersister; + bool result_ok; +} LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; /** - * A string that displays only printable characters, replacing control characters with - * [`core::char::REPLACEMENT_CHARACTER`]. + * Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network, + * but without the signature information. + * Decoding and encoding should not lead to information loss but may lead to different hashes. + * + * For methods without docs see the corresponding methods in [`Bolt11Invoice`]. */ -typedef struct MUST_USE_STRUCT LDKPrintableString { +typedef struct MUST_USE_STRUCT LDKRawBolt11Invoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePrintableString *inner; + LDKnativeRawBolt11Invoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPrintableString; - -/** - * A callback which is called when a [`Future`] completes. - * - * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be - * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`] - * instead. - * - * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule - * futures when they receive a wake, rather than immediately executing them. - */ -typedef struct LDKFutureCallback { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * The method which is called. - */ - void (*call)(const void *this_arg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKFutureCallback; +} LDKRawBolt11Invoice; /** - * A struct which can be used to select across many [`Future`]s at once without relying on a full - * async context. + * Recoverable signature */ -typedef struct MUST_USE_STRUCT LDKSleeper { +typedef struct MUST_USE_STRUCT LDKBolt11InvoiceSignature { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSleeper *inner; + LDKnativeBolt11InvoiceSignature *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSleeper; +} LDKBolt11InvoiceSignature; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + /** + * The element at position 0 + */ + struct LDKRawBolt11Invoice a; + /** + * The element at position 1 + */ + struct LDKThirtyTwoBytes b; + /** + * The element at position 2 + */ + struct LDKBolt11InvoiceSignature c; +} LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ; /** - * Configuration we set when applicable. - * - * Default::default() provides sane defaults. + * Payee public key */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { +typedef struct MUST_USE_STRUCT LDKPayeePubKey { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelHandshakeConfig *inner; + LDKnativePayeePubKey *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelHandshakeConfig; - - +} LDKPayeePubKey; /** - * Optional channel limits which are applied during channel creation. - * - * These limits are only applied to our counterparty's limits, not our own. - * - * Use 0/`::max_value()` as appropriate to skip checking. - * - * Provides sane defaults for most configurations. - * - * Most additional limits are disabled except those with which specify a default in individual - * field documentation. Note that this may result in barely-usable channels, but since they - * are applied mostly only to incoming channels that's not much of a problem. + * The contents of CResult_PayeePubKeyErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { +typedef union LDKCResult_PayeePubKeyErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelHandshakeLimits *inner; + struct LDKPayeePubKey *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelHandshakeLimits; + enum LDKSecp256k1Error *err; +} LDKCResult_PayeePubKeyErrorZPtr; + +/** + * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PayeePubKeyErrorZ { + /** + * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PayeePubKeyErrorZPtr contents; + /** + * Whether this CResult_PayeePubKeyErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PayeePubKeyErrorZ; /** - * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. + * Private routing information + * + * # Invariants + * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) * - * Default::default() provides sane defaults for most configurations - * (but currently with 0 relay fees!) */ -typedef struct MUST_USE_STRUCT LDKUserConfig { +typedef struct MUST_USE_STRUCT LDKPrivateRoute { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUserConfig *inner; + LDKnativePrivateRoute *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUserConfig; +} LDKPrivateRoute; + +/** + * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PrivateRouteZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPrivateRoute *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PrivateRouteZ; /** - * The best known block as identified by its hash and height. + * A timestamp that refers to a date after 1 January 1970. + * + * # Invariants + * + * The Unix timestamp representing the stored time has to be positive and no greater than + * [`MAX_TIMESTAMP`]. */ -typedef struct MUST_USE_STRUCT LDKBestBlock { +typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBestBlock *inner; + LDKnativePositiveTimestamp *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBestBlock; +} LDKPositiveTimestamp; /** - * The `Listen` trait is used to notify when blocks have been connected or disconnected from the - * chain. - * - * Useful when needing to replay chain data upon startup or as new chain events occur. Clients - * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. - * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers - * when needed. - * - * By using [`Listen::filtered_block_connected`] this interface supports clients fetching the - * entire header chain and only blocks with matching transaction data using BIP 157 filters or - * other similar filtering. + * The contents of CResult_PositiveTimestampCreationErrorZ */ -typedef struct LDKListen { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { /** - * Notifies the listener that a block was added at the given height, with the transaction data - * possibly filtered. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*filtered_block_connected)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + struct LDKPositiveTimestamp *result; /** - * Notifies the listener that a block was added at the given height. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); + enum LDKCreationError *err; +} LDKCResult_PositiveTimestampCreationErrorZPtr; + +/** + * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PositiveTimestampCreationErrorZ { /** - * Notifies the listener that a block was removed at the given height. + * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + union LDKCResult_PositiveTimestampCreationErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKListen; + bool result_ok; +} LDKCResult_PositiveTimestampCreationErrorZ; /** - * The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on - * chain or unconfirmed during a chain reorganization. - * - * Clients sourcing chain data using a transaction-oriented API should prefer this interface over - * [`Listen`]. For instance, an Electrum-based transaction sync implementation may implement - * [`Filter`] to subscribe to relevant transactions and unspent outputs it should monitor for - * on-chain activity. Then, it needs to notify LDK via this interface upon observing any changes - * with reference to the confirmation status of the monitored objects. - * - * # Use - * The intended use is as follows: - * - Call [`transactions_confirmed`] to notify LDK whenever any of the registered transactions or - * outputs are, respectively, confirmed or spent on chain. - * - Call [`transaction_unconfirmed`] to notify LDK whenever any transaction returned by - * [`get_relevant_txids`] is no longer confirmed in the block with the given block hash. - * - Call [`best_block_updated`] to notify LDK whenever a new chain tip becomes available. - * - * # Order - * - * Clients must call these methods in chain order. Specifically: - * - Transactions which are confirmed in a particular block must be given before transactions - * confirmed in a later block. - * - Dependent transactions within the same block must be given in topological order, possibly in - * separate calls. - * - All unconfirmed transactions must be given after the original confirmations and before *any* - * reconfirmations, i.e., [`transactions_confirmed`] and [`transaction_unconfirmed`] calls should - * never be interleaved, but always conduced *en bloc*. - * - Any reconfirmed transactions need to be explicitly unconfirmed before they are reconfirmed - * in regard to the new block. - * - * See individual method documentation for further details. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - * [`best_block_updated`]: Self::best_block_updated - * [`get_relevant_txids`]: Self::get_relevant_txids + * The contents of CResult_NoneBolt11SemanticErrorZ */ -typedef struct LDKConfirm { +typedef union LDKCResult_NoneBolt11SemanticErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * Note that this value is always NULL, as there are no contents in the OK variant */ - void *this_arg; + void *result; /** - * Notifies LDK of transactions confirmed in a block with a given header and height. - * - * Must be called for any transactions registered by [`Filter::register_tx`] or any - * transactions spending an output registered by [`Filter::register_output`]. Such transactions - * appearing in the same block do not need to be included in the same call; instead, multiple - * calls with additional transactions may be made so long as they are made in [chain order]. - * - * May be called before or after [`best_block_updated`] for the corresponding block. However, - * in the event of a chain reorganization, it must not be called with a `header` that is no - * longer in the chain as of the last call to [`best_block_updated`]. - * - * [chain order]: Confirm#order - * [`best_block_updated`]: Self::best_block_updated + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + enum LDKBolt11SemanticError *err; +} LDKCResult_NoneBolt11SemanticErrorZPtr; + +/** + * A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneBolt11SemanticErrorZ { /** - * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. - * - * Must be called for any transaction returned by [`get_relevant_txids`] if it has been - * reorganized out of the best chain or if it is no longer confirmed in the block with the - * given block hash. Once called, the given transaction will not be returned - * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. - * - * [`get_relevant_txids`]: Self::get_relevant_txids - * [`transactions_confirmed`]: Self::transactions_confirmed + * The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + union LDKCResult_NoneBolt11SemanticErrorZPtr contents; /** - * Notifies LDK of an update to the best header connected at the given height. - * - * Must be called whenever a new chain tip becomes available. May be skipped for intermediary - * blocks. + * Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. */ - void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + bool result_ok; +} LDKCResult_NoneBolt11SemanticErrorZ; + +/** + * The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ + */ +typedef union LDKCResult_Bolt11InvoiceBolt11SemanticErrorZPtr { /** - * Returns transactions that must be monitored for reorganization out of the chain along - * with the hash of the block as part of which it had been previously confirmed. - * - * Note that the returned `Option` might be `None` for channels created with LDK - * 0.0.112 and prior, in which case you need to manually track previous confirmations. - * - * Will include any transactions passed to [`transactions_confirmed`] that have insufficient - * confirmations to be safe from a chain reorganization. Will not include any transactions - * passed to [`transaction_unconfirmed`], unless later reconfirmed. - * - * Must be called to determine the subset of transactions that must be monitored for - * reorganization. Will be idempotent between calls but may change as a result of calls to the - * other interface methods. Thus, this is useful to determine which transactions must be - * given to [`transaction_unconfirmed`]. - * - * If any of the returned transactions are confirmed in a block other than the one with the - * given hash, they need to be unconfirmed and reconfirmed via [`transaction_unconfirmed`] and - * [`transactions_confirmed`], respectively. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_C2Tuple_TxidBlockHashZZ (*get_relevant_txids)(const void *this_arg); + struct LDKBolt11Invoice *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKConfirm; + enum LDKBolt11SemanticError *err; +} LDKCResult_Bolt11InvoiceBolt11SemanticErrorZPtr; /** - * `Persist` defines behavior for persisting channel monitors: this could mean - * writing once to disk, and/or uploading to one or more backup services. - * - * Each method can return three possible values: - * * If persistence (including any relevant `fsync()` calls) happens immediately, the - * implementation should return [`ChannelMonitorUpdateStatus::Completed`], 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 - * [`ChannelMonitorUpdateStatus::InProgress`] 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 - * [`ChannelMonitorUpdateStatus::PermanentFailure`], in which case the channel will likely be - * closed without broadcasting the latest state. See - * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more details. + * A CResult_Bolt11InvoiceBolt11SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::Bolt11SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKPersist { +typedef struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void *this_arg; + union LDKCResult_Bolt11InvoiceBolt11SemanticErrorZPtr contents; /** - * 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 [`ChannelMonitorUpdateStatus::InProgress`]. - * - * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` - * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`Writeable::write`]: crate::util::ser::Writeable::write + * Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ represents a success state. */ - enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + bool result_ok; +} LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ; + +/** + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_AddressZ { /** - * 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. - * - * 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* - * the set of channel monitors is given to the `ChannelManager` - * deserialization routine. See [`ChannelMonitor::update_monitor`] for - * applying a monitor update to a monitor. If full `ChannelMonitors` are - * persisted, then there is no need to persist individual updates. - * - * Note that there could be a performance tradeoff between persisting complete - * channel monitors on every update vs. persisting only updates and applying - * 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 [`ChannelMonitorUpdateStatus::InProgress`]. - * - * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, - * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and - * [`ChannelMonitorUpdateStatus`] 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 + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_id, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + struct LDKStr *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKPersist; + uintptr_t datalen; +} LDKCVec_AddressZ; /** - * An implementation of [`chain::Watch`] for monitoring channels. - * - * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by - * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally - * or used independently to monitor channels remotely. See the [module-level documentation] for - * details. - * - * Note that `ChainMonitor` should regularly trigger rebroadcasts/fee bumps of pending claims from - * a force-closed channel. This is crucial in preventing certain classes of pinning attacks, - * detecting substantial mempool feerate changes between blocks, and ensuring reliability if - * broadcasting fails. We recommend invoking this every 30 seconds, or lower if running in an - * environment with spotty connections, like on mobile. + * Description string * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [module-level documentation]: crate::chain::chainmonitor - * [`rebroadcast_pending_claims`]: Self::rebroadcast_pending_claims + * # Invariants + * The description can be at most 639 __bytes__ long */ -typedef struct MUST_USE_STRUCT LDKChainMonitor { +typedef struct MUST_USE_STRUCT LDKDescription { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChainMonitor *inner; + LDKnativeDescription *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChainMonitor; +} LDKDescription; /** - * A trait implemented for objects handling events from [`EventsProvider`]. - * - * An async variation also exists for implementations of [`EventsProvider`] that support async - * event handling. The async event handler should satisfy the generic bounds: `F: - * core::future::Future, H: Fn(Event) -> F`. + * The contents of CResult_DescriptionCreationErrorZ */ -typedef struct LDKEventHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_DescriptionCreationErrorZPtr { /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_event)(const void *this_arg, struct LDKEvent event); + struct LDKDescription *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKEventHandler; + enum LDKCreationError *err; +} LDKCResult_DescriptionCreationErrorZPtr; /** - * A trait indicating an object may generate events. - * - * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. - * - * Implementations of this trait may also feature an async version of event handling, as shown with - * [`ChannelManager::process_pending_events_async`] and - * [`ChainMonitor::process_pending_events_async`]. - * - * # Requirements - * - * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending - * event since the last invocation. - * - * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s - * and replay any unhandled events on startup. An [`Event`] is considered handled when - * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any - * relevant changes to disk *before* returning. - * - * Further, because an application may crash between an [`Event`] being handled and the - * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in - * effect, [`Event`]s may be replayed. - * - * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to - * consult the provider's documentation on the implication of processing events and how a handler - * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and - * [`ChainMonitor::process_pending_events`]). - * - * (C-not implementable) As there is likely no reason for a user to implement this trait on their - * own type(s). - * - * [`process_pending_events`]: Self::process_pending_events - * [`handle_event`]: EventHandler::handle_event - * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events - * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events - * [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async - * [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async + * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKEventsProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_DescriptionCreationErrorZ { /** - * Processes any events generated since the last call using the given event handler. - * - * See the trait-level documentation for requirements. + * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + union LDKCResult_DescriptionCreationErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_DescriptionCreationErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKEventsProvider; + bool result_ok; +} LDKCResult_DescriptionCreationErrorZ; /** - * Represents a valid secp256k1 secret key serialized as a 32 byte array. + * The contents of CResult_PrivateRouteCreationErrorZ */ -typedef struct LDKSecretKey { +typedef union LDKCResult_PrivateRouteCreationErrorZPtr { /** - * The bytes of the secret key + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint8_t bytes[32]; -} LDKSecretKey; - - + struct LDKPrivateRoute *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKCreationError *err; +} LDKCResult_PrivateRouteCreationErrorZPtr; /** - * Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a - * 32-byte seed for use as a BIP 32 extended key and derives keys from that. - * - * Your `node_id` is seed/0'. - * Unilateral closes may use seed/1'. - * Cooperative closes may use seed/2'. - * The two close keys may be needed to claim on-chain funds! - * - * This struct cannot be used for nodes that wish to support receiving phantom payments; - * [`PhantomKeysManager`] must be used instead. - * - * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any - * previously issued invoices and attempts to pay previous invoices will fail. + * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKKeysManager { +typedef struct LDKCResult_PrivateRouteCreationErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeKeysManager *inner; + union LDKCResult_PrivateRouteCreationErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. */ - bool is_owned; -} LDKKeysManager; - - + bool result_ok; +} LDKCResult_PrivateRouteCreationErrorZ; /** - * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node - * payments. - * - * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be - * paid to one of multiple nodes. This works because we encode the invoice route hints such that - * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment - * itself without ever needing to forward to this fake node. - * - * Phantom node payments are useful for load balancing between multiple LDK nodes. They also - * provide some fault tolerance, because payers will automatically retry paying other provided - * nodes in the case that one node goes down. - * - * Note that multi-path payments are not supported in phantom invoices for security reasons. - * Switching between this struct and [`KeysManager`] will invalidate any previously issued - * invoices and attempts to pay previous invoices will fail. + * The contents of CResult_OutPointDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { +typedef union LDKCResult_OutPointDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativePhantomKeysManager *inner; + struct LDKOutPoint *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKPhantomKeysManager; + struct LDKDecodeError *err; +} LDKCResult_OutPointDecodeErrorZPtr; + +/** + * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OutPointDecodeErrorZ { + /** + * The contents of this CResult_OutPointDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OutPointDecodeErrorZPtr contents; + /** + * Whether this CResult_OutPointDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OutPointDecodeErrorZ; /** - * Chain-related parameters used to construct a new `ChannelManager`. + * Lightning TLV uses a custom variable-length integer called `BigSize`. It is similar to Bitcoin's + * variable-length integers except that it is serialized in big-endian instead of little-endian. * - * Typically, the block-specific parameters are derived from the best block hash for the network, - * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters - * are not needed when deserializing a previously constructed `ChannelManager`. + * Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be + * encoded in several different ways, which we must check for at deserialization-time. Thus, if + * you're looking for an example of a variable-length integer to use for your own project, move + * along, this is a rather poor design. */ -typedef struct MUST_USE_STRUCT LDKChainParameters { +typedef struct MUST_USE_STRUCT LDKBigSize { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChainParameters *inner; + LDKnativeBigSize *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChainParameters; +} LDKBigSize; /** - * Strategies available to retry payment path failures. + * The contents of CResult_BigSizeDecodeErrorZ */ -typedef enum LDKRetry_Tag { +typedef union LDKCResult_BigSizeDecodeErrorZPtr { /** - * Max number of attempts to retry payment. - * - * Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a - * retry, and may retry multiple failed HTLCs at once if they failed around the same time and - * were retried along a route from a single call to [`Router::find_route_with_id`]. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKRetry_Attempts, + struct LDKBigSize *result; /** - * Time elapsed before abandoning retries for a payment. At least one attempt at payment is made; - * see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time. - * - * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKRetry_Timeout, + struct LDKDecodeError *err; +} LDKCResult_BigSizeDecodeErrorZPtr; + +/** + * A CResult_BigSizeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::ser::BigSize on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BigSizeDecodeErrorZ { /** - * Must be last for serialization purposes + * The contents of this CResult_BigSizeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKRetry_Sentinel, -} LDKRetry_Tag; - -typedef struct MUST_USE_STRUCT LDKRetry { - LDKRetry_Tag tag; - union { - struct { - uintptr_t attempts; - }; - struct { - uint64_t timeout; - }; - }; -} LDKRetry; + union LDKCResult_BigSizeDecodeErrorZPtr contents; + /** + * Whether this CResult_BigSizeDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BigSizeDecodeErrorZ; /** - * A trait indicating an object may generate message send events + * The contents of CResult_HostnameDecodeErrorZ */ -typedef struct LDKMessageSendEventsProvider { +typedef union LDKCResult_HostnameDecodeErrorZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKHostname *result; /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + struct LDKDecodeError *err; +} LDKCResult_HostnameDecodeErrorZPtr; + +/** + * A CResult_HostnameDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::ser::Hostname on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_HostnameDecodeErrorZ { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The contents of this CResult_HostnameDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*free)(void *this_arg); -} LDKMessageSendEventsProvider; + union LDKCResult_HostnameDecodeErrorZPtr contents; + /** + * Whether this CResult_HostnameDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_HostnameDecodeErrorZ; + + /** - * A trait to describe an object which can receive channel messages. + * A wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`] + * if the `Transaction`'s consensus-serialized length is <= u16::MAX. * - * Messages MAY be called in parallel when they originate from different `their_node_ids`, however - * they MUST NOT be called in parallel when the two calls have the same `their_node_id`. + * Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`. */ -typedef struct LDKChannelMessageHandler { +typedef struct MUST_USE_STRUCT LDKTransactionU16LenLimited { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *this_arg; + LDKnativeTransactionU16LenLimited *inner; /** - * Handle an incoming `open_channel` message from the given peer. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg); + bool is_owned; +} LDKTransactionU16LenLimited; + +/** + * The contents of CResult_TransactionU16LenLimitedNoneZ + */ +typedef union LDKCResult_TransactionU16LenLimitedNoneZPtr { /** - * Handle an incoming `accept_channel` message from the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAcceptChannel *NONNULL_PTR msg); + struct LDKTransactionU16LenLimited *result; /** - * Handle an incoming `funding_created` message from the given peer. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + void *err; +} LDKCResult_TransactionU16LenLimitedNoneZPtr; + +/** + * A CResult_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, + * containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TransactionU16LenLimitedNoneZ { /** - * Handle an incoming `funding_signed` message from the given peer. + * The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + union LDKCResult_TransactionU16LenLimitedNoneZPtr contents; /** - * Handle an incoming `channel_ready` message from the given peer. + * Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. */ - void (*handle_channel_ready)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReady *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_TransactionU16LenLimitedNoneZ; + +/** + * The contents of CResult_TransactionU16LenLimitedDecodeErrorZ + */ +typedef union LDKCResult_TransactionU16LenLimitedDecodeErrorZPtr { /** - * Handle an incoming `shutdown` message from the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg); + struct LDKTransactionU16LenLimited *result; /** - * Handle an incoming `closing_signed` message from the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + struct LDKDecodeError *err; +} LDKCResult_TransactionU16LenLimitedDecodeErrorZPtr; + +/** + * A CResult_TransactionU16LenLimitedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ { /** - * Handle an incoming `update_add_htlc` message from the given peer. + * The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + union LDKCResult_TransactionU16LenLimitedDecodeErrorZPtr contents; /** - * Handle an incoming `update_fulfill_htlc` message from the given peer. + * Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. */ - void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_TransactionU16LenLimitedDecodeErrorZ; + +/** + * The contents of CResult_UntrustedStringDecodeErrorZ + */ +typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { /** - * Handle an incoming `update_fail_htlc` message from the given peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + struct LDKUntrustedString *result; /** - * Handle an incoming `update_fail_malformed_htlc` message from the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + struct LDKDecodeError *err; +} LDKCResult_UntrustedStringDecodeErrorZPtr; + +/** + * A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UntrustedStringDecodeErrorZ { /** - * Handle an incoming `commitment_signed` message from the given peer. + * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + union LDKCResult_UntrustedStringDecodeErrorZPtr contents; /** - * Handle an incoming `revoke_and_ack` message from the given peer. + * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. */ - void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_UntrustedStringDecodeErrorZ; + +/** + * An error that may occur when making a payment. + */ +typedef enum LDKPaymentError_Tag { /** - * Handle an incoming `update_fee` message from the given peer. + * An error resulting from the provided [`Bolt11Invoice`] or payment hash. */ - void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + LDKPaymentError_Invoice, /** - * Handle an incoming `announcement_signatures` message from the given peer. + * An error occurring when sending a payment. */ - void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + LDKPaymentError_Sending, /** - * Indicates a connection to the peer failed/an existing connection was lost. + * Must be last for serialization purposes */ - void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + LDKPaymentError_Sentinel, +} LDKPaymentError_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentError { + LDKPaymentError_Tag tag; + union { + struct { + struct LDKStr invoice; + }; + struct { + enum LDKRetryableSendFailure sending; + }; + }; +} LDKPaymentError; + +/** + * The contents of CResult_PaymentIdPaymentErrorZ + */ +typedef union LDKCResult_PaymentIdPaymentErrorZPtr { /** - * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s). - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); + struct LDKThirtyTwoBytes *result; /** - * Handle an incoming `channel_reestablish` message from the given peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + struct LDKPaymentError *err; +} LDKCResult_PaymentIdPaymentErrorZPtr; + +/** + * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PaymentIdPaymentErrorZ { /** - * Handle an incoming `channel_update` message from the given peer. + * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + union LDKCResult_PaymentIdPaymentErrorZPtr contents; /** - * Handle an incoming `error` message from the given peer. + * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. */ - void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_PaymentIdPaymentErrorZ; + +/** + * The contents of CResult_NonePaymentErrorZ + */ +typedef union LDKCResult_NonePaymentErrorZPtr { /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + void *result; /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. - * - * Note that this method is called before [`Self::peer_connected`]. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + struct LDKPaymentError *err; +} LDKCResult_NonePaymentErrorZPtr; + +/** + * A CResult_NonePaymentErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NonePaymentErrorZ { /** - * Implementation of MessageSendEventsProvider for this object. + * The contents of this CResult_NonePaymentErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKMessageSendEventsProvider MessageSendEventsProvider; + union LDKCResult_NonePaymentErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_NonePaymentErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKChannelMessageHandler; - - + bool result_ok; +} LDKCResult_NonePaymentErrorZ; /** - * Arguments for the creation of a ChannelManager that are not deserialized. - * - * At a high-level, the process for deserializing a ChannelManager and resuming normal operation - * is: - * 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-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 - * you. If you deserialize an old ChannelManager (during which force-closure transactions may be - * 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 + * The contents of CResult_StringErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { +typedef union LDKCResult_StringErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelManagerReadArgs *inner; + struct LDKStr *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelManagerReadArgs; - - + enum LDKSecp256k1Error *err; +} LDKCResult_StringErrorZPtr; /** - * A set of keys that were HKDF-expanded from an initial call to - * [`NodeSigner::get_inbound_payment_key_material`]. - * - * [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material + * A CResult_StringErrorZ represents the result of a fallible operation, + * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKExpandedKey { +typedef struct LDKCResult_StringErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_StringErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeExpandedKey *inner; + union LDKCResult_StringErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_StringErrorZ represents a success state. */ - bool is_owned; -} LDKExpandedKey; + bool result_ok; +} LDKCResult_StringErrorZ; /** - * Proof that the sender knows the per-commitment secret of the previous commitment transaction. - * - * This is used to convince the recipient that the channel is at a certain commitment - * number even if they lost that data due to a local failure. Of course, the peer may lie - * and even later commitments may have been revoked. + * A path for sending an [`msgs::OnionMessage`]. */ -typedef struct MUST_USE_STRUCT LDKDataLossProtect { +typedef struct MUST_USE_STRUCT LDKOnionMessagePath { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDataLossProtect *inner; + LDKnativeOnionMessagePath *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDataLossProtect; +} LDKOnionMessagePath; /** - * A 3-byte byte array. + * The contents of CResult_OnionMessagePathNoneZ */ -typedef struct LDKThreeBytes { +typedef union LDKCResult_OnionMessagePathNoneZPtr { /** - * The three bytes + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint8_t data[3]; -} LDKThreeBytes; + struct LDKOnionMessagePath *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_OnionMessagePathNoneZPtr; /** - * A trait to describe an object which can receive routing messages. - * - * # Implementor DoS Warnings - * - * For messages enabled with the `gossip_queries` feature there are potential DoS vectors when - * handling inbound queries. Implementors using an on-disk network graph should be aware of - * repeated disk I/O for queries accessing different parts of the network graph. + * A CResult_OnionMessagePathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::messenger::OnionMessagePath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKRoutingMessageHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_OnionMessagePathNoneZ { /** - * Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, - * `false` or returning an `Err` otherwise. + * The contents of this CResult_OnionMessagePathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + union LDKCResult_OnionMessagePathNoneZPtr contents; /** - * Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` - * or returning an `Err` otherwise. + * Whether this CResult_OnionMessagePathNoneZ represents a success state. */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_OnionMessagePathNoneZ; + +/** + * Errors that may occur when [sending an onion message]. + * + * [sending an onion message]: OnionMessenger::send_onion_message + */ +typedef enum LDKSendError_Tag { /** - * Handle an incoming `channel_update` message, returning true if it should be forwarded on, - * `false` or returning an `Err` otherwise. + * Errored computing onion message packet keys. */ - struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + LDKSendError_Secp256k1, /** - * Gets channel announcements and updates required to dump our routing table to a remote node, - * starting at the `short_channel_id` indicated by `starting_point` and including announcements - * for a single channel. + * Because implementations such as Eclair will drop onion messages where the message packet + * exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size. */ - struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcement)(const void *this_arg, uint64_t starting_point); + LDKSendError_TooBigPacket, /** - * Gets a node announcement required to dump our routing table to a remote node, starting at - * the node *after* the provided pubkey and including up to one announcement immediately - * higher (as defined by `::cmp`) than `starting_point`. - * If `None` is provided for `starting_point`, we start at the first node. - * - * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The provided [`Destination`] was an invalid [`BlindedPath`], due to having fewer than two + * blinded hops. */ - struct LDKNodeAnnouncement (*get_next_node_announcement)(const void *this_arg, struct LDKNodeId starting_point); + LDKSendError_TooFewBlindedHops, /** - * Called when a connection is established with a peer. This can be used to - * perform routing table synchronization using a strategy defined by the - * implementor. - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. + * Our next-hop peer was offline or does not support onion message forwarding. */ - struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + LDKSendError_InvalidFirstHop, /** - * Handles the reply of a query we initiated to learn about channels - * for a given range of blocks. We can expect to receive one or more - * replies to a single query. + * Onion message contents must have a TLV type >= 64. */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + LDKSendError_InvalidMessage, /** - * Handles the reply of a query we initiated asking for routing gossip - * messages for a list of channels. We should receive this message when - * a node has completed its best effort to send us the pertaining routing - * gossip messages. + * Our next-hop peer's buffer was full or our total outbound buffer was full. */ - struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + LDKSendError_BufferFull, /** - * Handles when a peer asks us to send a list of `short_channel_id`s - * for the requested range of blocks. + * Failed to retrieve our node id from the provided [`NodeSigner`]. + * + * [`NodeSigner`]: crate::sign::NodeSigner */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + LDKSendError_GetNodeIdFailed, /** - * Handles when a peer asks us to send routing gossip messages for a - * list of `short_channel_id`s. + * We attempted to send to a blinded path where we are the introduction node, and failed to + * advance the blinded path to make the second hop the new introduction node. Either + * [`NodeSigner::ecdh`] failed, we failed to tweak the current blinding point to get the + * new blinding point, or we were attempting to send to ourselves. */ - struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + LDKSendError_BlindedPathAdvanceFailed, /** - * Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages - * pending some async action. While there is no guarantee of the rate of future messages, the - * caller should seek to reduce the rate of new gossip messages handled, especially - * [`ChannelAnnouncement`]s. + * Must be last for serialization purposes */ - bool (*processing_queue_high)(const void *this_arg); + LDKSendError_Sentinel, +} LDKSendError_Tag; + +typedef struct MUST_USE_STRUCT LDKSendError { + LDKSendError_Tag tag; + union { + struct { + enum LDKSecp256k1Error secp256k1; + }; + }; +} LDKSendError; + +/** + * The contents of CResult_NoneSendErrorZ + */ +typedef union LDKCResult_NoneSendErrorZPtr { /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + void *result; /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. - * - * Note that this method is called before [`Self::peer_connected`]. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + struct LDKSendError *err; +} LDKCResult_NoneSendErrorZPtr; + +/** + * A CResult_NoneSendErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneSendErrorZ { /** - * Implementation of MessageSendEventsProvider for this object. + * The contents of this CResult_NoneSendErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKMessageSendEventsProvider MessageSendEventsProvider; + union LDKCResult_NoneSendErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_NoneSendErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKRoutingMessageHandler; + bool result_ok; +} LDKCResult_NoneSendErrorZ; /** - * A trait indicating an object may generate onion messages to send + * The contents of CResult_BlindedPathNoneZ */ -typedef struct LDKOnionMessageProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_BlindedPathNoneZPtr { /** - * Gets the next pending onion message for the peer with the given node id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); + struct LDKBlindedPath *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*free)(void *this_arg); -} LDKOnionMessageProvider; + void *err; +} LDKCResult_BlindedPathNoneZPtr; /** - * A trait to describe an object that can receive onion messages. + * A CResult_BlindedPathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKOnionMessageHandler { +typedef struct LDKCResult_BlindedPathNoneZ { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The contents of this CResult_BlindedPathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void *this_arg; + union LDKCResult_BlindedPathNoneZPtr contents; /** - * Handle an incoming `onion_message` message from the given peer. + * Whether this CResult_BlindedPathNoneZ represents a success state. */ - void (*handle_onion_message)(const void *this_arg, struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg); + bool result_ok; +} LDKCResult_BlindedPathNoneZ; + +/** + * The contents of CResult_BlindedPathDecodeErrorZ + */ +typedef union LDKCResult_BlindedPathDecodeErrorZPtr { /** - * Called when a connection is established with a peer. Can be used to track which peers - * advertise onion message support and are online. - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + struct LDKBlindedPath *result; /** - * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to - * drop and refuse to forward onion messages to this peer. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + struct LDKDecodeError *err; +} LDKCResult_BlindedPathDecodeErrorZPtr; + +/** + * A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedPathDecodeErrorZ { /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. + * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + union LDKCResult_BlindedPathDecodeErrorZPtr contents; /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. - * - * Note that this method is called before [`Self::peer_connected`]. + * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. */ - struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + bool result_ok; +} LDKCResult_BlindedPathDecodeErrorZ; + +/** + * The contents of CResult_BlindedHopDecodeErrorZ + */ +typedef union LDKCResult_BlindedHopDecodeErrorZPtr { /** - * Implementation of OnionMessageProvider for this object. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOnionMessageProvider OnionMessageProvider; + struct LDKBlindedHop *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKOnionMessageHandler; + struct LDKDecodeError *err; +} LDKCResult_BlindedHopDecodeErrorZPtr; /** - * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) - * decoders. + * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCustomMessageReader { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_BlindedHopDecodeErrorZ { /** - * Decodes a custom message to `CustomMessageType`. If the given message type is known to the - * implementation and the message could be decoded, must return `Ok(Some(message))`. If the - * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error - * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_COption_TypeZDecodeErrorZ (*read)(const void *this_arg, uint16_t message_type, struct LDKu8slice buffer); + union LDKCResult_BlindedHopDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKCustomMessageReader; + bool result_ok; +} LDKCResult_BlindedHopDecodeErrorZ; /** - * A handler provided to [`PeerManager`] for reading and handling custom messages. - * - * [BOLT 1] specifies a custom message type range for use with experimental or application-specific - * messages. `CustomMessageHandler` allows for user-defined handling of such types. See the - * [`lightning_custom_message`] crate for tools useful in composing more than one custom handler. - * - * [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md - * [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message + * The contents of CResult_InvoiceErrorDecodeErrorZ */ -typedef struct LDKCustomMessageHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_InvoiceErrorDecodeErrorZPtr { /** - * Handles the given message sent from `sender_node_id`, possibly producing messages for - * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] - * to send. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_NoneLightningErrorZ (*handle_custom_message)(const void *this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id); + struct LDKInvoiceError *result; /** - * Returns the list of pending messages that were generated by the handler, clearing the list - * in the process. Each message is paired with the node id of the intended recipient. If no - * connection to the node exists, then the message is simply not sent. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_C2Tuple_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg); + struct LDKDecodeError *err; +} LDKCResult_InvoiceErrorDecodeErrorZPtr; + +/** + * A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceErrorDecodeErrorZ { /** - * Implementation of CustomMessageReader for this object. + * The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCustomMessageReader CustomMessageReader; + union LDKCResult_InvoiceErrorDecodeErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKCustomMessageHandler; + bool result_ok; +} LDKCResult_InvoiceErrorDecodeErrorZ; /** - * A dummy struct which implements `RoutingMessageHandler` without storing any routing information - * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. + * + * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction + * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via + * [`Confirm::transactions_confirmed`]. + * + * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and + * may have been spent there. See [`Filter::register_output`] for details. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected */ -typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { +typedef struct MUST_USE_STRUCT LDKWatchedOutput { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeIgnoringMessageHandler *inner; + LDKnativeWatchedOutput *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKIgnoringMessageHandler; +} LDKWatchedOutput; /** - * Handler for custom onion messages. If you are using [`SimpleArcOnionMessenger`], - * [`SimpleRefOnionMessenger`], or prefer to ignore inbound custom onion messages, - * [`IgnoringMessageHandler`] must be provided to [`OnionMessenger::new`]. Otherwise, a custom - * implementation of this trait must be provided, with [`CustomMessage`] specifying the supported - * message types. + * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to + * channels. * - * See [`OnionMessenger`] for example usage. + * This is useful in order to have a [`Watch`] implementation convey to a chain source which + * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in + * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If + * receiving full blocks from a chain source, any further filtering is unnecessary. * - * [`IgnoringMessageHandler`]: crate::ln::peer_handler::IgnoringMessageHandler - * [`CustomMessage`]: Self::CustomMessage + * After an output has been registered, subsequent block retrievals from the chain source must not + * exclude any transactions matching the new criteria nor any in-block descendants of such + * transactions. + * + * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` + * should not block on I/O. Implementations should instead queue the newly monitored data to be + * processed later. Then, in order to block until the data has been processed, any [`Watch`] + * invocation that has called the `Filter` must return [`InProgress`]. + * + * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress + * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki + * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki */ -typedef struct LDKCustomOnionMessageHandler { +typedef struct LDKFilter { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; /** - * Called with the custom message that was received. + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. */ - void (*handle_custom_message)(const void *this_arg, struct LDKCustomOnionMessageContents msg); + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** - * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the - * message type is unknown. + * Registers interest in spends of a transaction output. + * + * Note that this method might be called during processing of a new block. You therefore need + * to ensure that also dependent output spents within an already connected block are correctly + * handled, e.g., by re-scanning the block in question whenever new outputs have been + * registered mid-processing. */ - struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ (*read_custom_message)(const void *this_arg, uint64_t message_type, struct LDKu8slice buffer); + void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKCustomOnionMessageHandler; - - +} LDKFilter; /** - * A dummy struct which implements `ChannelMessageHandler` without having any channels. - * You can provide one of these as the route_handler in a MessageHandler. + * An enum which can either contain a crate::lightning::chain::Filter or not */ -typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { +typedef enum LDKCOption_FilterZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter */ - LDKnativeErroringMessageHandler *inner; + LDKCOption_FilterZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_FilterZ contains nothing */ - bool is_owned; -} LDKErroringMessageHandler; + LDKCOption_FilterZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_FilterZ_Sentinel, +} LDKCOption_FilterZ_Tag; + +typedef struct LDKCOption_FilterZ { + LDKCOption_FilterZ_Tag tag; + union { + struct { + struct LDKFilter some; + }; + }; +} LDKCOption_FilterZ; /** - * Provides references to trait impls which handle different types of messages. + * A read-only reference to a current ChannelMonitor. + * + * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is + * released. */ -typedef struct MUST_USE_STRUCT LDKMessageHandler { +typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMessageHandler *inner; + LDKnativeLockedChannelMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMessageHandler; +} LDKLockedChannelMonitor; /** - * Provides an object which can be used to send data to and which uniquely identifies a connection - * to a remote host. You will need to be able to generate multiple of these which meet Eq and - * implement Hash to meet the PeerManager API. - * - * For efficiency, [`Clone`] should be relatively cheap for this type. - * - * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original - * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it - * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no - * further calls to the [`PeerManager`] related to the original socket occur. This allows you to - * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish - * to simply use another value which is guaranteed to be globally unique instead. + * The contents of CResult_LockedChannelMonitorNoneZ */ -typedef struct LDKSocketDescriptor { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_LockedChannelMonitorNoneZPtr { /** - * Attempts to send some data from the given slice to the peer. - * - * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be - * called and further write attempts may occur until that time. - * - * If the returned size is smaller than `data.len()`, a - * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be - * written. Additionally, until a `send_data` event completes fully, no further - * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to - * prevent denial-of-service issues, you should not read or buffer any data from the socket - * until then. - * - * If a [`PeerManager::read_event`] call on this descriptor had previously returned true - * (indicating that read events should be paused to prevent DoS in the send buffer), - * `resume_read` may be set indicating that read events on this descriptor should resume. A - * `resume_read` of false carries no meaning, and should not cause any action. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); + struct LDKLockedChannelMonitor *result; /** - * Disconnect the socket pointed to by this SocketDescriptor. - * - * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this - * call (doing so is a noop). + * Note that this value is always NULL, as there are no contents in the Err variant */ - void (*disconnect_socket)(void *this_arg); + void *err; +} LDKCResult_LockedChannelMonitorNoneZPtr; + +/** + * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, + * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_LockedChannelMonitorNoneZ { /** - * Checks if two objects are equal given this object's this_arg pointer and another object. + * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + union LDKCResult_LockedChannelMonitorNoneZPtr contents; /** - * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. - * This is used, for example, for inclusion of this object in a hash map. + * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. */ - uint64_t (*hash)(const void *this_arg); + bool result_ok; +} LDKCResult_LockedChannelMonitorNoneZ; + +/** + * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_OutPointZ { /** - * Called, if set, after this SocketDescriptor has been cloned into a duplicate object. - * The new SocketDescriptor is provided, and should be mutated as needed to perform a - * deep copy of the object pointed to by this_arg or avoid any double-freeing. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void (*cloned)(struct LDKSocketDescriptor *NONNULL_PTR new_SocketDescriptor); + struct LDKOutPoint *data; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The number of elements pointed to by `data`. */ - void (*free)(void *this_arg); -} LDKSocketDescriptor; + uintptr_t datalen; +} LDKCVec_OutPointZ; /** - * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls - * socket events into messages which it passes on to its [`MessageHandler`]. - * - * Locks are taken internally, so you must never assume that reentrancy from a - * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock. - * - * Calls to [`read_event`] will decode relevant messages and pass them to the - * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of - * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any - * [`PeerManager`] functions related to the same connection must occur only in serial, making new - * calls only after previous ones have returned. - * - * Rather than using a plain [`PeerManager`], it is preferable to use either a [`SimpleArcPeerManager`] - * a [`SimpleRefPeerManager`], for conciseness. See their documentation for more details, but - * essentially you should default to using a [`SimpleRefPeerManager`], and use a - * [`SimpleArcPeerManager`] when you require a `PeerManager` with a static lifetime, such as when - * you're using lightning-net-tokio. - * - * [`read_event`]: PeerManager::read_event + * An opaque identifier describing a specific [`Persist`] method call. */ -typedef struct MUST_USE_STRUCT LDKPeerManager { +typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePeerManager *inner; + LDKnativeMonitorUpdateId *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPeerManager; - - +} LDKMonitorUpdateId; /** - * Static channel fields used to build transactions given per-commitment fields, organized by - * broadcaster/countersignatory. - * - * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the - * as_holder_broadcastable and as_counterparty_broadcastable functions. + * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { +typedef struct LDKCVec_MonitorUpdateIdZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeDirectedChannelTransactionParameters *inner; + struct LDKMonitorUpdateId *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKDirectedChannelTransactionParameters; - - + uintptr_t datalen; +} LDKCVec_MonitorUpdateIdZ; /** - * Features used within an `offer`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKOfferFeatures { +typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeOfferFeatures *inner; + struct LDKOutPoint a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKOfferFeatures; - - + struct LDKCVec_MonitorUpdateIdZ b; +} LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ; /** - * Features used within an `invoice_request`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKInvoiceRequestFeatures { +typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeInvoiceRequestFeatures *inner; + struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKInvoiceRequestFeatures; - - + uintptr_t datalen; +} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; /** - * Features used within an `invoice`. + * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. */ -typedef struct MUST_USE_STRUCT LDKBolt12InvoiceFeatures { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeBolt12InvoiceFeatures *inner; +typedef struct LDKPersister { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - bool is_owned; -} LDKBolt12InvoiceFeatures; - -/** - * Integer in the range `0..=16` - */ -typedef struct LDKWitnessVersion { - uint8_t _0; -} LDKWitnessVersion; - - - -/** - * A semantically valid [`Invoice`] that hasn't been signed. - */ -typedef struct MUST_USE_STRUCT LDKUnsignedInvoice { + void *this_arg; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. */ - LDKnativeUnsignedInvoice *inner; + struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. */ - bool is_owned; -} LDKUnsignedInvoice; - - - -/** - * A semantically valid [`InvoiceRequest`] that hasn't been signed. - */ -typedef struct MUST_USE_STRUCT LDKUnsignedInvoiceRequest { + struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - LDKnativeUnsignedInvoiceRequest *inner; + struct LDKCResult_NoneErrorZ (*persist_scorer)(const void *this_arg, const struct LDKWriteableScore *NONNULL_PTR scorer); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool is_owned; -} LDKUnsignedInvoiceRequest; + void (*free)(void *this_arg); +} LDKPersister; /** - * An `InvoiceRequest` is a request for an [`Invoice`] formulated from an [`Offer`]. - * - * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request - * specifies these such that its recipient can send an invoice for payment. - * - * [`Invoice`]: crate::offers::invoice::Invoice - * [`Offer`]: crate::offers::offer::Offer + * A string that displays only printable characters, replacing control characters with + * [`core::char::REPLACEMENT_CHARACTER`]. */ -typedef struct MUST_USE_STRUCT LDKInvoiceRequest { +typedef struct MUST_USE_STRUCT LDKPrintableString { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceRequest *inner; + LDKnativePrintableString *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceRequest; - - +} LDKPrintableString; /** - * An `Offer` is a potentially long-lived proposal for payment of a good or service. - * - * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a - * customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to - * cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. - * - * Offers may be denominated in currency other than bitcoin but are ultimately paid using the - * latter. + * A callback which is called when a [`Future`] completes. * - * Through the use of [`BlindedPath`]s, offers provide recipient privacy. + * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be + * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`] + * instead. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Invoice`]: crate::offers::invoice::Invoice + * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule + * futures when they receive a wake, rather than immediately executing them. */ -typedef struct MUST_USE_STRUCT LDKOffer { +typedef struct LDKFutureCallback { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKnativeOffer *inner; + void *this_arg; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The method which is called. */ - bool is_owned; -} LDKOffer; + void (*call)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFutureCallback; /** - * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or - * another currency. + * A struct which can be used to select across many [`Future`]s at once without relying on a full + * async context. */ -typedef struct MUST_USE_STRUCT LDKAmount { +typedef struct MUST_USE_STRUCT LDKSleeper { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeAmount *inner; + LDKnativeSleeper *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKAmount; +} LDKSleeper; /** - * Quantity of items supported by an [`Offer`]. + * Configuration we set when applicable. + * + * Default::default() provides sane defaults. */ -typedef struct MUST_USE_STRUCT LDKQuantity { +typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeQuantity *inner; + LDKnativeChannelHandshakeConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKQuantity; +} LDKChannelHandshakeConfig; /** - * A `Refund` is a request to send an [`Invoice`] without a preceding [`Offer`]. + * Optional channel limits which are applied during channel creation. * - * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to - * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a - * bitcoin ATM. + * These limits are only applied to our counterparty's limits, not our own. * - * [`Invoice`]: crate::offers::invoice::Invoice - * [`Offer`]: crate::offers::offer::Offer + * Use 0/`::max_value()` as appropriate to skip checking. + * + * Provides sane defaults for most configurations. + * + * Most additional limits are disabled except those with which specify a default in individual + * field documentation. Note that this may result in barely-usable channels, but since they + * are applied mostly only to incoming channels that's not much of a problem. */ -typedef struct MUST_USE_STRUCT LDKRefund { +typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeRefund *inner; + LDKnativeChannelHandshakeLimits *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKRefund; +} LDKChannelHandshakeLimits; /** - * Receives and validates network updates from peers, - * stores authentic and relevant data as a network graph. - * This network graph is then used for routing payments. - * Provides interface to help with initial routing sync by - * serving historical announcements. + * A parallel struct to [`ChannelConfig`] to define partial updates. */ -typedef struct MUST_USE_STRUCT LDKP2PGossipSync { +typedef struct MUST_USE_STRUCT LDKChannelConfigUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeP2PGossipSync *inner; + LDKnativeChannelConfigUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKP2PGossipSync; +} LDKChannelConfigUpdate; /** - * A read-only view of [`NetworkGraph`]. + * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. + * + * Default::default() provides sane defaults for most configurations + * (but currently with 0 relay fees!) */ -typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph { +typedef struct MUST_USE_STRUCT LDKUserConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReadOnlyNetworkGraph *inner; + LDKnativeUserConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKReadOnlyNetworkGraph; +} LDKUserConfig; /** - * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a - * source node to a target node. + * The best known block as identified by its hash and height. */ -typedef struct MUST_USE_STRUCT LDKDirectedChannelInfo { +typedef struct MUST_USE_STRUCT LDKBestBlock { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDirectedChannelInfo *inner; + LDKnativeBestBlock *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDirectedChannelInfo; +} LDKBestBlock; /** - * The effective capacity of a channel for routing purposes. + * The `Listen` trait is used to notify when blocks have been connected or disconnected from the + * chain. * - * While this may be smaller than the actual channel capacity, amounts greater than - * [`Self::as_msat`] should not be routed through the channel. + * Useful when needing to replay chain data upon startup or as new chain events occur. Clients + * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. + * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers + * when needed. + * + * By using [`Listen::filtered_block_connected`] this interface supports clients fetching the + * entire header chain and only blocks with matching transaction data using BIP 157 filters or + * other similar filtering. */ -typedef enum LDKEffectiveCapacity_Tag { - /** - * The available liquidity in the channel known from being a channel counterparty, and thus a - * direct hop. - */ - LDKEffectiveCapacity_ExactLiquidity, +typedef struct LDKListen { /** - * The maximum HTLC amount in one direction as advertised on the gossip network. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKEffectiveCapacity_MaximumHTLC, + void *this_arg; /** - * The total capacity of the channel as determined by the funding transaction. + * Notifies the listener that a block was added at the given height, with the transaction data + * possibly filtered. */ - LDKEffectiveCapacity_Total, + void (*filtered_block_connected)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** - * A capacity sufficient to route any payment, typically used for private channels provided by - * an invoice. + * Notifies the listener that a block was added at the given height. */ - LDKEffectiveCapacity_Infinite, + void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); /** - * A capacity that is unknown possibly because either the chain state is unavailable to know - * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network. + * Notifies the listener that a block was removed at the given height. */ - LDKEffectiveCapacity_Unknown, + void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); /** - * Must be last for serialization purposes + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - LDKEffectiveCapacity_Sentinel, -} LDKEffectiveCapacity_Tag; + void (*free)(void *this_arg); +} LDKListen; -typedef struct LDKEffectiveCapacity_LDKExactLiquidity_Body { +/** + * The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on + * chain or unconfirmed during a chain reorganization. + * + * Clients sourcing chain data using a transaction-oriented API should prefer this interface over + * [`Listen`]. For instance, an Electrum-based transaction sync implementation may implement + * [`Filter`] to subscribe to relevant transactions and unspent outputs it should monitor for + * on-chain activity. Then, it needs to notify LDK via this interface upon observing any changes + * with reference to the confirmation status of the monitored objects. + * + * # Use + * The intended use is as follows: + * - Call [`transactions_confirmed`] to notify LDK whenever any of the registered transactions or + * outputs are, respectively, confirmed or spent on chain. + * - Call [`transaction_unconfirmed`] to notify LDK whenever any transaction returned by + * [`get_relevant_txids`] is no longer confirmed in the block with the given block hash. + * - Call [`best_block_updated`] to notify LDK whenever a new chain tip becomes available. + * + * # Order + * + * Clients must call these methods in chain order. Specifically: + * - Transactions which are confirmed in a particular block must be given before transactions + * confirmed in a later block. + * - Dependent transactions within the same block must be given in topological order, possibly in + * separate calls. + * - All unconfirmed transactions must be given after the original confirmations and before *any* + * reconfirmations, i.e., [`transactions_confirmed`] and [`transaction_unconfirmed`] calls should + * never be interleaved, but always conduced *en bloc*. + * - Any reconfirmed transactions need to be explicitly unconfirmed before they are reconfirmed + * in regard to the new block. + * + * See individual method documentation for further details. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * [`best_block_updated`]: Self::best_block_updated + * [`get_relevant_txids`]: Self::get_relevant_txids + */ +typedef struct LDKConfirm { /** - * Either the inbound or outbound liquidity depending on the direction, denominated in - * millisatoshi. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - uint64_t liquidity_msat; -} LDKEffectiveCapacity_LDKExactLiquidity_Body; - -typedef struct LDKEffectiveCapacity_LDKMaximumHTLC_Body { + void *this_arg; /** - * The maximum HTLC amount denominated in millisatoshi. + * Notifies LDK of transactions confirmed in a block with a given header and height. + * + * Must be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Confirm#order + * [`best_block_updated`]: Self::best_block_updated */ - uint64_t amount_msat; -} LDKEffectiveCapacity_LDKMaximumHTLC_Body; - -typedef struct LDKEffectiveCapacity_LDKTotal_Body { + void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); /** - * The funding amount denominated in millisatoshi. + * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. + * + * Must be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain or if it is no longer confirmed in the block with the + * given block hash. Once called, the given transaction will not be returned + * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed */ - uint64_t capacity_msat; + void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); /** - * The maximum HTLC amount denominated in millisatoshi. + * Notifies LDK of an update to the best header connected at the given height. + * + * Must be called whenever a new chain tip becomes available. May be skipped for intermediary + * blocks. */ - uint64_t htlc_maximum_msat; -} LDKEffectiveCapacity_LDKTotal_Body; - -typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { - LDKEffectiveCapacity_Tag tag; - union { - LDKEffectiveCapacity_LDKExactLiquidity_Body exact_liquidity; - LDKEffectiveCapacity_LDKMaximumHTLC_Body maximum_htlc; - LDKEffectiveCapacity_LDKTotal_Body total; - }; -} LDKEffectiveCapacity; - - - -/** - * A [`Router`] implemented using [`find_route`]. - */ -typedef struct MUST_USE_STRUCT LDKDefaultRouter { + void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Returns transactions that must be monitored for reorganization out of the chain along + * with the hash of the block as part of which it had been previously confirmed. + * + * Note that the returned `Option` might be `None` for channels created with LDK + * 0.0.112 and prior, in which case you need to manually track previous confirmations. + * + * Will include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Will not include any transactions + * passed to [`transaction_unconfirmed`], unless later reconfirmed. + * + * Must be called to determine the subset of transactions that must be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions must be + * given to [`transaction_unconfirmed`]. + * + * If any of the returned transactions are confirmed in a block other than the one with the + * given hash, they need to be unconfirmed and reconfirmed via [`transaction_unconfirmed`] and + * [`transactions_confirmed`], respectively. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed */ - LDKnativeDefaultRouter *inner; + struct LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ (*get_relevant_txids)(const void *this_arg); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool is_owned; -} LDKDefaultRouter; - - + void (*free)(void *this_arg); +} LDKConfirm; /** - * [`Score`] implementation that factors in in-flight HTLC liquidity. + * `Persist` defines behavior for persisting channel monitors: this could mean + * writing once to disk, and/or uploading to one or more backup services. * - * Useful for custom [`Router`] implementations to wrap their [`Score`] on-the-fly when calling - * [`find_route`]. + * Each method can return three possible values: + * * If persistence (including any relevant `fsync()` calls) happens immediately, the + * implementation should return [`ChannelMonitorUpdateStatus::Completed`], 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 + * [`ChannelMonitorUpdateStatus::InProgress`] while the update continues in the background. + * Once the update completes, [`ChainMonitor::channel_monitor_updated`] should be called with + * the corresponding [`MonitorUpdateId`]. * - * [`Score`]: crate::routing::scoring::Score + * 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 + * [`ChannelMonitorUpdateStatus::PermanentFailure`], in which case the channel will likely be + * closed without broadcasting the latest state. See + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more details. */ -typedef struct MUST_USE_STRUCT LDKScorerAccountingForInFlightHtlcs { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeScorerAccountingForInFlightHtlcs *inner; +typedef struct LDKPersist { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - bool is_owned; -} LDKScorerAccountingForInFlightHtlcs; - -/** - * Routing hints for the tail of the route. - */ -typedef enum LDKHints_Tag { + void *this_arg; /** - * The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves - * will be included in the final [`Route`]. + * 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 [`ChannelMonitorUpdateStatus::InProgress`]. + * + * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` + * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`Writeable::write`]: crate::util::ser::Writeable::write */ - LDKHints_Blinded, + enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); /** - * The recipient included these route hints in their BOLT11 invoice. + * 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. + * + * 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* + * the set of channel monitors is given to the `ChannelManager` + * deserialization routine. See [`ChannelMonitor::update_monitor`] for + * applying a monitor update to a monitor. If full `ChannelMonitors` are + * persisted, then there is no need to persist individual updates. + * + * Note that there could be a performance tradeoff between persisting complete + * channel monitors on every update vs. persisting only updates and applying + * 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 [`ChannelMonitorUpdateStatus::InProgress`]. + * + * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, + * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and + * [`ChannelMonitorUpdateStatus`] 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 */ - LDKHints_Clear, + enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_id, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); /** - * Must be last for serialization purposes + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - LDKHints_Sentinel, -} LDKHints_Tag; - -typedef struct MUST_USE_STRUCT LDKHints { - LDKHints_Tag tag; - union { - struct { - struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded; - }; - struct { - struct LDKCVec_RouteHintZ clear; - }; - }; -} LDKHints; + void (*free)(void *this_arg); +} LDKPersist; /** - * A concrete implementation of [`LockableScore`] which supports multi-threading. + * An implementation of [`chain::Watch`] for monitoring channels. + * + * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by + * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally + * or used independently to monitor channels remotely. See the [module-level documentation] for + * details. + * + * Note that `ChainMonitor` should regularly trigger rebroadcasts/fee bumps of pending claims from + * a force-closed channel. This is crucial in preventing certain classes of pinning attacks, + * detecting substantial mempool feerate changes between blocks, and ensuring reliability if + * broadcasting fails. We recommend invoking this every 30 seconds, or lower if running in an + * environment with spotty connections, like on mobile. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [module-level documentation]: crate::chain::chainmonitor + * [`rebroadcast_pending_claims`]: Self::rebroadcast_pending_claims */ -typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { +typedef struct MUST_USE_STRUCT LDKChainMonitor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMultiThreadedLockableScore *inner; + LDKnativeChainMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMultiThreadedLockableScore; - - +} LDKChainMonitor; /** - * A locked `MultiThreadedLockableScore`. + * A trait implemented for objects handling events from [`EventsProvider`]. + * + * An async variation also exists for implementations of [`EventsProvider`] that support async + * event handling. The async event handler should satisfy the generic bounds: `F: + * core::future::Future, H: Fn(Event) -> F`. */ -typedef struct MUST_USE_STRUCT LDKMultiThreadedScoreLock { +typedef struct LDKEventHandler { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKnativeMultiThreadedScoreLock *inner; + void *this_arg; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. */ - bool is_owned; -} LDKMultiThreadedScoreLock; + void (*handle_event)(const void *this_arg, struct LDKEvent event); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEventHandler; + +/** + * A trait indicating an object may generate events. + * + * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. + * + * Implementations of this trait may also feature an async version of event handling, as shown with + * [`ChannelManager::process_pending_events_async`] and + * [`ChainMonitor::process_pending_events_async`]. + * + * # Requirements + * + * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending + * event since the last invocation. + * + * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s + * and replay any unhandled events on startup. An [`Event`] is considered handled when + * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any + * relevant changes to disk *before* returning. + * + * Further, because an application may crash between an [`Event`] being handled and the + * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in + * effect, [`Event`]s may be replayed. + * + * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to + * consult the provider's documentation on the implication of processing events and how a handler + * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and + * [`ChainMonitor::process_pending_events`]). + * + * (C-not implementable) As there is likely no reason for a user to implement this trait on their + * own type(s). + * + * [`process_pending_events`]: Self::process_pending_events + * [`handle_event`]: EventHandler::handle_event + * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events + * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events + * [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async + * [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async + */ +typedef struct LDKEventsProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Processes any events generated since the last call using the given event handler. + * + * See the trait-level documentation for requirements. + */ + void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEventsProvider; /** - * Parameters for configuring [`ProbabilisticScorer`]. - * - * Used to configure base, liquidity, and amount penalties, the sum of which comprises the channel - * penalty (i.e., the amount in msats willing to be paid to avoid routing through the channel). + * Chain-related parameters used to construct a new `ChannelManager`. * - * The penalty applied to any channel by the [`ProbabilisticScorer`] is the sum of each of the - * parameters here. + * Typically, the block-specific parameters are derived from the best block hash for the network, + * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters + * are not needed when deserializing a previously constructed `ChannelManager`. */ -typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { +typedef struct MUST_USE_STRUCT LDKChainParameters { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeProbabilisticScoringParameters *inner; + LDKnativeChainParameters *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKProbabilisticScoringParameters; +} LDKChainParameters; +/** + * Strategies available to retry payment path failures. + */ +typedef enum LDKRetry_Tag { + /** + * Max number of attempts to retry payment. + * + * Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a + * retry, and may retry multiple failed HTLCs at once if they failed around the same time and + * were retried along a route from a single call to [`Router::find_route_with_id`]. + */ + LDKRetry_Attempts, + /** + * Time elapsed before abandoning retries for a payment. At least one attempt at payment is made; + * see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time. + * + * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + */ + LDKRetry_Timeout, + /** + * Must be last for serialization purposes + */ + LDKRetry_Sentinel, +} LDKRetry_Tag; +typedef struct MUST_USE_STRUCT LDKRetry { + LDKRetry_Tag tag; + union { + struct { + uintptr_t attempts; + }; + struct { + uint64_t timeout; + }; + }; +} LDKRetry; /** - * A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be - * used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending - * and receiving custom onion messages is supported. - * - * # Example + * A trait indicating an object may generate message send events + */ +typedef struct LDKMessageSendEventsProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. + */ + struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKMessageSendEventsProvider; + +/** + * A trait to describe an object which can receive channel messages. * - * ``` - * # extern crate bitcoin; - * # use bitcoin::hashes::_export::_core::time::Duration; - * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; - * # use lightning::blinded_path::BlindedPath; - * # use lightning::chain::keysinterface::KeysManager; - * # use lightning::ln::peer_handler::IgnoringMessageHandler; - * # use lightning::onion_message::messenger::{Destination, OnionMessenger}; - * # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents}; - * # use lightning::util::logger::{Logger, Record}; - * # use lightning::util::ser::{Writeable, Writer}; - * # use lightning::io; - * # use std::sync::Arc; - * # struct FakeLogger; - * # impl Logger for FakeLogger { - * # fn log(&self, record: &Record) { unimplemented!() } - * # } - * # let seed = [42u8; 32]; - * # let time = Duration::from_secs(123456); - * # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos()); - * # let logger = Arc::new(FakeLogger {}); - * # let node_secret = SecretKey::from_slice(&hex::decode(\"0101010101010101010101010101010101010101010101010101010101010101\").unwrap()[..]).unwrap(); - * # let secp_ctx = Secp256k1::new(); - * # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret); - * # let (hop_node_id2, hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1, hop_node_id1); - * # let destination_node_id = hop_node_id1; - * # let your_custom_message_handler = IgnoringMessageHandler {}; - * // Create the onion messenger. This must use the same `keys_manager` as is passed to your - * // ChannelManager. - * let onion_messenger = OnionMessenger::new(&keys_manager, &keys_manager, logger, &your_custom_message_handler); + * Messages MAY be called in parallel when they originate from different `their_node_ids`, however + * they MUST NOT be called in parallel when the two calls have the same `their_node_id`. + */ +typedef struct LDKChannelMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle an incoming `open_channel` message from the given peer. + */ + void (*handle_open_channel)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg); + /** + * Handle an incoming `open_channel2` message from the given peer. + */ + void (*handle_open_channel_v2)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKOpenChannelV2 *NONNULL_PTR msg); + /** + * Handle an incoming `accept_channel` message from the given peer. + */ + void (*handle_accept_channel)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAcceptChannel *NONNULL_PTR msg); + /** + * Handle an incoming `accept_channel2` message from the given peer. + */ + void (*handle_accept_channel_v2)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAcceptChannelV2 *NONNULL_PTR msg); + /** + * Handle an incoming `funding_created` message from the given peer. + */ + void (*handle_funding_created)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + /** + * Handle an incoming `funding_signed` message from the given peer. + */ + void (*handle_funding_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + /** + * Handle an incoming `channel_ready` message from the given peer. + */ + void (*handle_channel_ready)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReady *NONNULL_PTR msg); + /** + * Handle an incoming `shutdown` message from the given peer. + */ + void (*handle_shutdown)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg); + /** + * Handle an incoming `closing_signed` message from the given peer. + */ + void (*handle_closing_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + /** + * Handle an incoming `tx_add_input message` from the given peer. + */ + void (*handle_tx_add_input)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxAddInput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_add_output` message from the given peer. + */ + void (*handle_tx_add_output)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxAddOutput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_remove_input` message from the given peer. + */ + void (*handle_tx_remove_input)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxRemoveInput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_remove_output` message from the given peer. + */ + void (*handle_tx_remove_output)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxRemoveOutput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_complete message` from the given peer. + */ + void (*handle_tx_complete)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxComplete *NONNULL_PTR msg); + /** + * Handle an incoming `tx_signatures` message from the given peer. + */ + void (*handle_tx_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxSignatures *NONNULL_PTR msg); + /** + * Handle an incoming `tx_init_rbf` message from the given peer. + */ + void (*handle_tx_init_rbf)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxInitRbf *NONNULL_PTR msg); + /** + * Handle an incoming `tx_ack_rbf` message from the given peer. + */ + void (*handle_tx_ack_rbf)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxAckRbf *NONNULL_PTR msg); + /** + * Handle an incoming `tx_abort message` from the given peer. + */ + void (*handle_tx_abort)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKTxAbort *NONNULL_PTR msg); + /** + * Handle an incoming `update_add_htlc` message from the given peer. + */ + void (*handle_update_add_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fulfill_htlc` message from the given peer. + */ + void (*handle_update_fulfill_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fail_htlc` message from the given peer. + */ + void (*handle_update_fail_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fail_malformed_htlc` message from the given peer. + */ + void (*handle_update_fail_malformed_htlc)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `commitment_signed` message from the given peer. + */ + void (*handle_commitment_signed)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + /** + * Handle an incoming `revoke_and_ack` message from the given peer. + */ + void (*handle_revoke_and_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + /** + * Handle an incoming `update_fee` message from the given peer. + */ + void (*handle_update_fee)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + /** + * Handle an incoming `announcement_signatures` message from the given peer. + */ + void (*handle_announcement_signatures)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + /** + * Indicates a connection to the peer failed/an existing connection was lost. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s). + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); + /** + * Handle an incoming `channel_reestablish` message from the given peer. + */ + void (*handle_channel_reestablish)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); + /** + * Handle an incoming `channel_update` message from the given peer. + */ + void (*handle_channel_update)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Handle an incoming `error` message from the given peer. + */ + void (*handle_error)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports. + * + * If it's `None`, then no particular network chain hash compatibility will be enforced when + * connecting to peers. + */ + struct LDKCOption_CVec_ChainHashZZ (*get_genesis_hashes)(const void *this_arg); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKChannelMessageHandler; + + + +/** + * Arguments for the creation of a ChannelManager that are not deserialized. * - * # struct YourCustomMessage {} - * impl Writeable for YourCustomMessage { - * \tfn write(&self, w: &mut W) -> Result<(), io::Error> { - * \t\t# Ok(()) - * \t\t// Write your custom onion message to `w` - * \t} - * } - * impl CustomOnionMessageContents for YourCustomMessage { - * \tfn tlv_type(&self) -> u64 { - * \t\t# let your_custom_message_type = 42; - * \t\tyour_custom_message_type - * \t} - * } - * // Send a custom onion message to a node id. - * let intermediate_hops = [hop_node_id1, hop_node_id2]; - * let reply_path = None; - * # let your_custom_message = YourCustomMessage {}; - * let message = OnionMessageContents::Custom(your_custom_message); - * onion_messenger.send_onion_message(&intermediate_hops, Destination::Node(destination_node_id), message, reply_path); + * At a high-level, the process for deserializing a ChannelManager and resuming normal operation + * is: + * 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`]. * - * // Create a blinded path to yourself, for someone to send an onion message to. - * # let your_node_id = hop_node_id1; - * let hops = [hop_node_id3, hop_node_id4, your_node_id]; - * let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap(); + * 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`]. * - * // Send a custom onion message to a blinded path. - * # let intermediate_hops = [hop_node_id1, hop_node_id2]; - * let reply_path = None; - * # let your_custom_message = YourCustomMessage {}; - * let message = OnionMessageContents::Custom(your_custom_message); - * onion_messenger.send_onion_message(&intermediate_hops, Destination::BlindedPath(blinded_path), message, reply_path); - * ``` + * 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 + * you. If you deserialize an old ChannelManager (during which force-closure transactions may be + * 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. * - * [offers]: - * [`OnionMessenger`]: crate::onion_message::OnionMessenger + * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor */ -typedef struct MUST_USE_STRUCT LDKOnionMessenger { +typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeOnionMessenger *inner; + LDKnativeChannelManagerReadArgs *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKOnionMessenger; +} LDKChannelManagerReadArgs; + + /** - * The destination of an onion message. + * A set of keys that were HKDF-expanded from an initial call to + * [`NodeSigner::get_inbound_payment_key_material`]. + * + * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material */ -typedef enum LDKDestination_Tag { +typedef struct MUST_USE_STRUCT LDKExpandedKey { /** - * We're sending this onion message to a node. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKDestination_Node, + LDKnativeExpandedKey *inner; /** - * We're sending this onion message to a blinded path. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKDestination_BlindedPath, + bool is_owned; +} LDKExpandedKey; + +/** + * A 3-byte byte array. + */ +typedef struct LDKThreeBytes { /** - * Must be last for serialization purposes + * The three bytes */ - LDKDestination_Sentinel, -} LDKDestination_Tag; + uint8_t data[3]; +} LDKThreeBytes; -typedef struct MUST_USE_STRUCT LDKDestination { - LDKDestination_Tag tag; - union { - struct { - struct LDKPublicKey node; - }; - struct { - struct LDKBlindedPath blinded_path; - }; - }; -} LDKDestination; +/** + * A trait to describe an object which can receive routing messages. + * + * # Implementor DoS Warnings + * + * For messages enabled with the `gossip_queries` feature there are potential DoS vectors when + * handling inbound queries. Implementors using an on-disk network graph should be aware of + * repeated disk I/O for queries accessing different parts of the network graph. + */ +typedef struct LDKRoutingMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, + * `false` or returning an `Err` otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_node_announcement)(const void *this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); + /** + * Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` + * or returning an `Err` otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_channel_announcement)(const void *this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); + /** + * Handle an incoming `channel_update` message, returning true if it should be forwarded on, + * `false` or returning an `Err` otherwise. + */ + struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Gets channel announcements and updates required to dump our routing table to a remote node, + * starting at the `short_channel_id` indicated by `starting_point` and including announcements + * for a single channel. + */ + struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ (*get_next_channel_announcement)(const void *this_arg, uint64_t starting_point); + /** + * Gets a node announcement required to dump our routing table to a remote node, starting at + * the node *after* the provided pubkey and including up to one announcement immediately + * higher (as defined by `::cmp`) than `starting_point`. + * If `None` is provided for `starting_point`, we start at the first node. + * + * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKNodeAnnouncement (*get_next_node_announcement)(const void *this_arg, struct LDKNodeId starting_point); + /** + * Called when a connection is established with a peer. This can be used to + * perform routing table synchronization using a strategy defined by the + * implementor. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + /** + * Handles the reply of a query we initiated to learn about channels + * for a given range of blocks. We can expect to receive one or more + * replies to a single query. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_reply_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + /** + * Handles the reply of a query we initiated asking for routing gossip + * messages for a list of channels. We should receive this message when + * a node has completed its best effort to send us the pertaining routing + * gossip messages. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_reply_short_channel_ids_end)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + /** + * Handles when a peer asks us to send a list of `short_channel_id`s + * for the requested range of blocks. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_channel_range)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); + /** + * Handles when a peer asks us to send routing gossip messages for a + * list of `short_channel_id`s. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_query_short_channel_ids)(const void *this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + /** + * Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages + * pending some async action. While there is no guarantee of the rate of future messages, the + * caller should seek to reduce the rate of new gossip messages handled, especially + * [`ChannelAnnouncement`]s. + */ + bool (*processing_queue_high)(const void *this_arg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of MessageSendEventsProvider for this object. + */ + struct LDKMessageSendEventsProvider MessageSendEventsProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKRoutingMessageHandler; + +/** + * A trait indicating an object may generate onion messages to send + */ +typedef struct LDKOnionMessageProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOnionMessageProvider; + +/** + * A trait to describe an object that can receive onion messages. + */ +typedef struct LDKOnionMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle an incoming `onion_message` message from the given peer. + */ + void (*handle_onion_message)(const void *this_arg, struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg); + /** + * Called when a connection is established with a peer. Can be used to track which peers + * advertise onion message support and are online. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + /** + * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to + * drop and refuse to forward onion messages to this peer. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of OnionMessageProvider for this object. + */ + struct LDKOnionMessageProvider OnionMessageProvider; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOnionMessageHandler; + +/** + * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) + * decoders. + */ +typedef struct LDKCustomMessageReader { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Decodes a custom message to `CustomMessageType`. If the given message type is known to the + * implementation and the message could be decoded, must return `Ok(Some(message))`. If the + * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error + * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. + */ + struct LDKCResult_COption_TypeZDecodeErrorZ (*read)(const void *this_arg, uint16_t message_type, struct LDKu8slice buffer); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCustomMessageReader; + +/** + * A handler provided to [`PeerManager`] for reading and handling custom messages. + * + * [BOLT 1] specifies a custom message type range for use with experimental or application-specific + * messages. `CustomMessageHandler` allows for user-defined handling of such types. See the + * [`lightning_custom_message`] crate for tools useful in composing more than one custom handler. + * + * [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md + * [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message + */ +typedef struct LDKCustomMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handles the given message sent from `sender_node_id`, possibly producing messages for + * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] + * to send. + */ + struct LDKCResult_NoneLightningErrorZ (*handle_custom_message)(const void *this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id); + /** + * Returns the list of pending messages that were generated by the handler, clearing the list + * in the process. Each message is paired with the node id of the intended recipient. If no + * connection to the node exists, then the message is simply not sent. + */ + struct LDKCVec_C2Tuple_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + * + * [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement + */ + struct LDKNodeFeatures (*provided_node_features)(const void *this_arg); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * [`Init`]: crate::ln::msgs::Init + */ + struct LDKInitFeatures (*provided_init_features)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Implementation of CustomMessageReader for this object. + */ + struct LDKCustomMessageReader CustomMessageReader; + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCustomMessageHandler; + + + +/** + * A dummy struct which implements `RoutingMessageHandler` without storing any routing information + * or doing any processing. You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKIgnoringMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeIgnoringMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKIgnoringMessageHandler; + +/** + * A handler for an [`OnionMessage`] containing a BOLT 12 Offers message as its payload. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage + */ +typedef struct LDKOffersMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handles the given message by either responding with an [`Bolt12Invoice`], sending a payment, + * or replying with an error. + */ + struct LDKCOption_OffersMessageZ (*handle_message)(const void *this_arg, struct LDKOffersMessage message); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOffersMessageHandler; + +/** + * Handler for custom onion messages. If you are using [`SimpleArcOnionMessenger`], + * [`SimpleRefOnionMessenger`], or prefer to ignore inbound custom onion messages, + * [`IgnoringMessageHandler`] must be provided to [`OnionMessenger::new`]. Otherwise, a custom + * implementation of this trait must be provided, with [`CustomMessage`] specifying the supported + * message types. + * + * See [`OnionMessenger`] for example usage. + * + * [`IgnoringMessageHandler`]: crate::ln::peer_handler::IgnoringMessageHandler + * [`CustomMessage`]: Self::CustomMessage + */ +typedef struct LDKCustomOnionMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Called with the custom message that was received, returning a response to send, if any. + */ + struct LDKCOption_CustomOnionMessageContentsZ (*handle_custom_message)(const void *this_arg, struct LDKCustomOnionMessageContents msg); + /** + * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the + * message type is unknown. + */ + struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ (*read_custom_message)(const void *this_arg, uint64_t message_type, struct LDKu8slice buffer); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCustomOnionMessageHandler; + + + +/** + * A dummy struct which implements `ChannelMessageHandler` without having any channels. + * You can provide one of these as the route_handler in a MessageHandler. + */ +typedef struct MUST_USE_STRUCT LDKErroringMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeErroringMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKErroringMessageHandler; + + + +/** + * Provides references to trait impls which handle different types of messages. + */ +typedef struct MUST_USE_STRUCT LDKMessageHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMessageHandler; + +/** + * Provides an object which can be used to send data to and which uniquely identifies a connection + * to a remote host. You will need to be able to generate multiple of these which meet Eq and + * implement Hash to meet the PeerManager API. + * + * For efficiency, [`Clone`] should be relatively cheap for this type. + * + * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original + * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it + * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no + * further calls to the [`PeerManager`] related to the original socket occur. This allows you to + * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish + * to simply use another value which is guaranteed to be globally unique instead. + */ +typedef struct LDKSocketDescriptor { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Attempts to send some data from the given slice to the peer. + * + * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. + * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be + * called and further write attempts may occur until that time. + * + * If the returned size is smaller than `data.len()`, a + * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be + * written. Additionally, until a `send_data` event completes fully, no further + * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to + * prevent denial-of-service issues, you should not read or buffer any data from the socket + * until then. + * + * If a [`PeerManager::read_event`] call on this descriptor had previously returned true + * (indicating that read events should be paused to prevent DoS in the send buffer), + * `resume_read` may be set indicating that read events on this descriptor should resume. A + * `resume_read` of false carries no meaning, and should not cause any action. + */ + uintptr_t (*send_data)(void *this_arg, struct LDKu8slice data, bool resume_read); + /** + * Disconnect the socket pointed to by this SocketDescriptor. + * + * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this + * call (doing so is a noop). + */ + void (*disconnect_socket)(void *this_arg); + /** + * Checks if two objects are equal given this object's this_arg pointer and another object. + */ + bool (*eq)(const void *this_arg, const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + /** + * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. + * This is used, for example, for inclusion of this object in a hash map. + */ + uint64_t (*hash)(const void *this_arg); + /** + * Called, if set, after this SocketDescriptor has been cloned into a duplicate object. + * The new SocketDescriptor is provided, and should be mutated as needed to perform a + * deep copy of the object pointed to by this_arg or avoid any double-freeing. + */ + void (*cloned)(struct LDKSocketDescriptor *NONNULL_PTR new_SocketDescriptor); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSocketDescriptor; + + + +/** + * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls + * socket events into messages which it passes on to its [`MessageHandler`]. + * + * Locks are taken internally, so you must never assume that reentrancy from a + * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock. + * + * Calls to [`read_event`] will decode relevant messages and pass them to the + * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of + * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any + * [`PeerManager`] functions related to the same connection must occur only in serial, making new + * calls only after previous ones have returned. + * + * Rather than using a plain [`PeerManager`], it is preferable to use either a [`SimpleArcPeerManager`] + * a [`SimpleRefPeerManager`], for conciseness. See their documentation for more details, but + * essentially you should default to using a [`SimpleRefPeerManager`], and use a + * [`SimpleArcPeerManager`] when you require a `PeerManager` with a static lifetime, such as when + * you're using lightning-net-tokio. + * + * [`read_event`]: PeerManager::read_event + */ +typedef struct MUST_USE_STRUCT LDKPeerManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePeerManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPeerManager; + + + +/** + * Static channel fields used to build transactions given per-commitment fields, organized by + * broadcaster/countersignatory. + * + * This is derived from the holder/counterparty-organized ChannelTransactionParameters via the + * as_holder_broadcastable and as_counterparty_broadcastable functions. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelTransactionParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDirectedChannelTransactionParameters; + + + +/** + * Features used within an `offer`. + */ +typedef struct MUST_USE_STRUCT LDKOfferFeatures { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOfferFeatures *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOfferFeatures; + + + +/** + * Features used within an `invoice_request`. + */ +typedef struct MUST_USE_STRUCT LDKInvoiceRequestFeatures { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequestFeatures *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequestFeatures; + +/** + * Integer in the range `0..=16` + */ +typedef struct LDKWitnessVersion { + uint8_t _0; +} LDKWitnessVersion; + + + +/** + * A semantically valid [`Bolt12Invoice`] that hasn't been signed. + */ +typedef struct MUST_USE_STRUCT LDKUnsignedBolt12Invoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnsignedBolt12Invoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedBolt12Invoice; + + + +/** + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + */ +typedef struct MUST_USE_STRUCT LDKErroneousField { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeErroneousField *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKErroneousField; + + + +/** + * A semantically valid [`InvoiceRequest`] that hasn't been signed. + */ +typedef struct MUST_USE_STRUCT LDKUnsignedInvoiceRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnsignedInvoiceRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedInvoiceRequest; + + + +/** + * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or + * another currency. + */ +typedef struct MUST_USE_STRUCT LDKAmount { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeAmount *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKAmount; + + + +/** + * Quantity of items supported by an [`Offer`]. + */ +typedef struct MUST_USE_STRUCT LDKQuantity { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQuantity *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKQuantity; + + + +/** + * Receives and validates network updates from peers, + * stores authentic and relevant data as a network graph. + * This network graph is then used for routing payments. + * Provides interface to help with initial routing sync by + * serving historical announcements. + */ +typedef struct MUST_USE_STRUCT LDKP2PGossipSync { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeP2PGossipSync *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKP2PGossipSync; + + + +/** + * A read-only view of [`NetworkGraph`]. + */ +typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReadOnlyNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKReadOnlyNetworkGraph; + + + +/** + * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a + * source node to a target node. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDirectedChannelInfo; + +/** + * The effective capacity of a channel for routing purposes. + * + * While this may be smaller than the actual channel capacity, amounts greater than + * [`Self::as_msat`] should not be routed through the channel. + */ +typedef enum LDKEffectiveCapacity_Tag { + /** + * The available liquidity in the channel known from being a channel counterparty, and thus a + * direct hop. + */ + LDKEffectiveCapacity_ExactLiquidity, + /** + * The maximum HTLC amount in one direction as advertised on the gossip network. + */ + LDKEffectiveCapacity_AdvertisedMaxHTLC, + /** + * The total capacity of the channel as determined by the funding transaction. + */ + LDKEffectiveCapacity_Total, + /** + * A capacity sufficient to route any payment, typically used for private channels provided by + * an invoice. + */ + LDKEffectiveCapacity_Infinite, + /** + * The maximum HTLC amount as provided by an invoice route hint. + */ + LDKEffectiveCapacity_HintMaxHTLC, + /** + * A capacity that is unknown possibly because either the chain state is unavailable to know + * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network. + */ + LDKEffectiveCapacity_Unknown, + /** + * Must be last for serialization purposes + */ + LDKEffectiveCapacity_Sentinel, +} LDKEffectiveCapacity_Tag; + +typedef struct LDKEffectiveCapacity_LDKExactLiquidity_Body { + /** + * Either the inbound or outbound liquidity depending on the direction, denominated in + * millisatoshi. + */ + uint64_t liquidity_msat; +} LDKEffectiveCapacity_LDKExactLiquidity_Body; + +typedef struct LDKEffectiveCapacity_LDKAdvertisedMaxHTLC_Body { + /** + * The maximum HTLC amount denominated in millisatoshi. + */ + uint64_t amount_msat; +} LDKEffectiveCapacity_LDKAdvertisedMaxHTLC_Body; + +typedef struct LDKEffectiveCapacity_LDKTotal_Body { + /** + * The funding amount denominated in millisatoshi. + */ + uint64_t capacity_msat; + /** + * The maximum HTLC amount denominated in millisatoshi. + */ + uint64_t htlc_maximum_msat; +} LDKEffectiveCapacity_LDKTotal_Body; + +typedef struct LDKEffectiveCapacity_LDKHintMaxHTLC_Body { + /** + * The maximum HTLC amount denominated in millisatoshi. + */ + uint64_t amount_msat; +} LDKEffectiveCapacity_LDKHintMaxHTLC_Body; + +typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { + LDKEffectiveCapacity_Tag tag; + union { + LDKEffectiveCapacity_LDKExactLiquidity_Body exact_liquidity; + LDKEffectiveCapacity_LDKAdvertisedMaxHTLC_Body advertised_max_htlc; + LDKEffectiveCapacity_LDKTotal_Body total; + LDKEffectiveCapacity_LDKHintMaxHTLC_Body hint_max_htlc; + }; +} LDKEffectiveCapacity; + + + +/** + * A [`Router`] implemented using [`find_route`]. + */ +typedef struct MUST_USE_STRUCT LDKDefaultRouter { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDefaultRouter *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDefaultRouter; + + + +/** + * [`Score`] implementation that factors in in-flight HTLC liquidity. + * + * Useful for custom [`Router`] implementations to wrap their [`Score`] on-the-fly when calling + * [`find_route`]. + * + * [`Score`]: crate::routing::scoring::Score + */ +typedef struct MUST_USE_STRUCT LDKScorerAccountingForInFlightHtlcs { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeScorerAccountingForInFlightHtlcs *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKScorerAccountingForInFlightHtlcs; + +/** + * The recipient of a payment, differing based on whether they've hidden their identity with route + * blinding. + */ +typedef enum LDKPayee_Tag { + /** + * The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves + * will be included in the final [`Route`]. + */ + LDKPayee_Blinded, + /** + * The recipient included these route hints in their BOLT11 invoice. + */ + LDKPayee_Clear, + /** + * Must be last for serialization purposes + */ + LDKPayee_Sentinel, +} LDKPayee_Tag; + +typedef struct LDKPayee_LDKBlinded_Body { + /** + * Aggregated routing info and blinded paths, for routing to the payee without knowing their + * node id. + */ + struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints; + /** + * Features supported by the payee. + * + * May be set from the payee's invoice. May be `None` if the invoice does not contain any + * features. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKBolt12InvoiceFeatures features; +} LDKPayee_LDKBlinded_Body; + +typedef struct LDKPayee_LDKClear_Body { + /** + * The node id of the payee. + */ + struct LDKPublicKey node_id; + /** + * Hints for routing to the payee, containing channels connecting the payee to public nodes. + */ + struct LDKCVec_RouteHintZ route_hints; + /** + * 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`]: PaymentParameters::for_keysend + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKBolt11InvoiceFeatures features; + /** + * The minimum CLTV delta at the end of the route. This value must not be zero. + */ + uint32_t final_cltv_expiry_delta; +} LDKPayee_LDKClear_Body; + +typedef struct MUST_USE_STRUCT LDKPayee { + LDKPayee_Tag tag; + union { + LDKPayee_LDKBlinded_Body blinded; + LDKPayee_LDKClear_Body clear; + }; +} LDKPayee; + + + +/** + * A concrete implementation of [`LockableScore`] which supports multi-threading. + */ +typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMultiThreadedLockableScore *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMultiThreadedLockableScore; + + + +/** + * A locked `MultiThreadedLockableScore`. + */ +typedef struct MUST_USE_STRUCT LDKMultiThreadedScoreLock { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMultiThreadedScoreLock *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMultiThreadedScoreLock; + + + +/** + * Parameters for configuring [`ProbabilisticScorer`]. + * + * Used to configure decay parameters that are static throughout the lifetime of the scorer. + * these decay parameters affect the score of the channel penalty and are not changed on a + * per-route penalty cost call. + */ +typedef struct MUST_USE_STRUCT LDKProbabilisticScoringDecayParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeProbabilisticScoringDecayParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKProbabilisticScoringDecayParameters; + + + +/** + * Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a + * 32-byte seed for use as a BIP 32 extended key and derives keys from that. + * + * Your `node_id` is seed/0'. + * Unilateral closes may use seed/1'. + * Cooperative closes may use seed/2'. + * The two close keys may be needed to claim on-chain funds! + * + * This struct cannot be used for nodes that wish to support receiving phantom payments; + * [`PhantomKeysManager`] must be used instead. + * + * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any + * previously issued invoices and attempts to pay previous invoices will fail. + */ +typedef struct MUST_USE_STRUCT LDKKeysManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeKeysManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKKeysManager; + + + +/** + * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node + * payments. + * + * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be + * paid to one of multiple nodes. This works because we encode the invoice route hints such that + * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment + * itself without ever needing to forward to this fake node. + * + * Phantom node payments are useful for load balancing between multiple LDK nodes. They also + * provide some fault tolerance, because payers will automatically retry paying other provided + * nodes in the case that one node goes down. + * + * Note that multi-path payments are not supported in phantom invoices for security reasons. + * Switching between this struct and [`KeysManager`] will invalidate any previously issued + * invoices and attempts to pay previous invoices will fail. + */ +typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePhantomKeysManager *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPhantomKeysManager; + +/** + * The destination of an onion message. + */ +typedef enum LDKDestination_Tag { + /** + * We're sending this onion message to a node. + */ + LDKDestination_Node, + /** + * We're sending this onion message to a blinded path. + */ + LDKDestination_BlindedPath, + /** + * Must be last for serialization purposes + */ + LDKDestination_Sentinel, +} LDKDestination_Tag; + +typedef struct MUST_USE_STRUCT LDKDestination { + LDKDestination_Tag tag; + union { + struct { + struct LDKPublicKey node; + }; + struct { + struct LDKBlindedPath blinded_path; + }; + }; +} LDKDestination; + +/** + * A trait defining behavior for routing an [`OnionMessage`]. + * + * [`OnionMessage`]: msgs::OnionMessage + */ +typedef struct LDKMessageRouter { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. + * + * [`OnionMessage`]: msgs::OnionMessage + */ + struct LDKCResult_OnionMessagePathNoneZ (*find_path)(const void *this_arg, struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKMessageRouter; + + + +/** + * A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be + * used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending + * and receiving custom onion messages is supported. + * + * # Example + * + * ``` + * # extern crate bitcoin; + * # use bitcoin::hashes::_export::_core::time::Duration; + * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; + * # use lightning::blinded_path::BlindedPath; + * # use lightning::sign::KeysManager; + * # use lightning::ln::peer_handler::IgnoringMessageHandler; + * # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessenger, OnionMessagePath}; + * # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents}; + * # use lightning::util::logger::{Logger, Record}; + * # use lightning::util::ser::{Writeable, Writer}; + * # use lightning::io; + * # use std::sync::Arc; + * # struct FakeLogger; + * # impl Logger for FakeLogger { + * # fn log(&self, record: &Record) { unimplemented!() } + * # } + * # struct FakeMessageRouter {} + * # impl MessageRouter for FakeMessageRouter { + * # fn find_path(&self, sender: PublicKey, peers: Vec, destination: Destination) -> Result { + * # unimplemented!() + * # } + * # } + * # let seed = [42u8; 32]; + * # let time = Duration::from_secs(123456); + * # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos()); + * # let logger = Arc::new(FakeLogger {}); + * # let node_secret = SecretKey::from_slice(&hex::decode(\"0101010101010101010101010101010101010101010101010101010101010101\").unwrap()[..]).unwrap(); + * # let secp_ctx = Secp256k1::new(); + * # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret); + * # let (hop_node_id2, hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1, hop_node_id1); + * # let destination_node_id = hop_node_id1; + * # let message_router = Arc::new(FakeMessageRouter {}); + * # let custom_message_handler = IgnoringMessageHandler {}; + * # let offers_message_handler = IgnoringMessageHandler {}; + * // Create the onion messenger. This must use the same `keys_manager` as is passed to your + * // ChannelManager. + * let onion_messenger = OnionMessenger::new( + * &keys_manager, &keys_manager, logger, message_router, &offers_message_handler, + * &custom_message_handler + * ); + * + * # struct YourCustomMessage {} + * impl Writeable for YourCustomMessage { + * \tfn write(&self, w: &mut W) -> Result<(), io::Error> { + * \t\t# Ok(()) + * \t\t// Write your custom onion message to `w` + * \t} + * } + * impl CustomOnionMessageContents for YourCustomMessage { + * \tfn tlv_type(&self) -> u64 { + * \t\t# let your_custom_message_type = 42; + * \t\tyour_custom_message_type + * \t} + * } + * // Send a custom onion message to a node id. + * let path = OnionMessagePath { + * \tintermediate_nodes: vec![hop_node_id1, hop_node_id2], + * \tdestination: Destination::Node(destination_node_id), + * }; + * let reply_path = None; + * # let your_custom_message = YourCustomMessage {}; + * let message = OnionMessageContents::Custom(your_custom_message); + * onion_messenger.send_onion_message(path, message, reply_path); + * + * // Create a blinded path to yourself, for someone to send an onion message to. + * # let your_node_id = hop_node_id1; + * let hops = [hop_node_id3, hop_node_id4, your_node_id]; + * let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap(); + * + * // Send a custom onion message to a blinded path. + * let path = OnionMessagePath { + * \tintermediate_nodes: vec![hop_node_id1, hop_node_id2], + * \tdestination: Destination::BlindedPath(blinded_path), + * }; + * let reply_path = None; + * # let your_custom_message = YourCustomMessage {}; + * let message = OnionMessageContents::Custom(your_custom_message); + * onion_messenger.send_onion_message(path, message, reply_path); + * ``` + * + * [offers]: + * [`OnionMessenger`]: crate::onion_message::OnionMessenger + */ +typedef struct MUST_USE_STRUCT LDKOnionMessenger { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOnionMessenger *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOnionMessenger; + + + +/** + * A [`MessageRouter`] that always fails. + */ +typedef struct MUST_USE_STRUCT LDKDefaultMessageRouter { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDefaultMessageRouter *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDefaultMessageRouter; + +/** + * The contents of an onion message. In the context of offers, this would be the invoice, invoice + * request, or invoice error. + */ +typedef enum LDKOnionMessageContents_Tag { + /** + * A message related to BOLT 12 Offers. + */ + LDKOnionMessageContents_Offers, + /** + * A custom onion message specified by the user. + */ + LDKOnionMessageContents_Custom, + /** + * Must be last for serialization purposes + */ + LDKOnionMessageContents_Sentinel, +} LDKOnionMessageContents_Tag; + +typedef struct MUST_USE_STRUCT LDKOnionMessageContents { + LDKOnionMessageContents_Tag tag; + union { + struct { + struct LDKOffersMessage offers; + }; + struct { + struct LDKCustomOnionMessageContents custom; + }; + }; +} LDKOnionMessageContents; + + + +/** + * The parameters required to derive a channel signer via [`SignerProvider`]. + */ +typedef struct MUST_USE_STRUCT LDKChannelDerivationParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelDerivationParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelDerivationParameters; + +/** + * An abstraction over a bitcoin wallet that can perform coin selection over a set of UTXOs and can + * sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC, + * which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`], + * which can provide a default implementation of this trait when used with [`Wallet`]. + */ +typedef struct LDKCoinSelectionSource { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are + * available to spend. Implementations are free to pick their coin selection algorithm of + * choice, as long as the following requirements are met: + * + * 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction + * throughout coin selection, but must not be returned as part of the result. + * 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction + * throughout coin selection. In some cases, like when funding an anchor transaction, this + * set is empty. Implementations should ensure they handle this correctly on their end, + * e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be + * provided, in which case a zero-value empty OP_RETURN output can be used instead. + * 3. Enough inputs must be selected/contributed for the resulting transaction (including the + * inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`. + * + * Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of + * the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require + * providing the full input weight. Failing to do so may lead to underestimating fee bumps and + * delaying block inclusion. + * + * The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they + * can be re-used within new fee-bumped iterations of the original claiming transaction, + * ensuring that claims don't double spend each other. If a specific `claim_id` has never had a + * transaction associated with it, and all of the available UTXOs have already been assigned to + * other claims, implementations must be willing to double spend their UTXOs. The choice of + * which UTXOs to double spend is left to the implementation, but it must strive to keep the + * set of other claims being double spent to a minimum. + */ + struct LDKCResult_CoinSelectionNoneZ (*select_confirmed_utxos)(const void *this_arg, struct LDKThirtyTwoBytes claim_id, struct LDKCVec_InputZ must_spend, struct LDKCVec_TxOutZ must_pay_to, uint32_t target_feerate_sat_per_1000_weight); + /** + * Signs and provides the full witness for all inputs within the transaction known to the + * trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]). + */ + struct LDKCResult_TransactionNoneZ (*sign_tx)(const void *this_arg, struct LDKTransaction tx); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKCoinSelectionSource; + +/** + * An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to + * provide a default implementation to [`CoinSelectionSource`]. + */ +typedef struct LDKWalletSource { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns all UTXOs, with at least 1 confirmation each, that are available to spend. + */ + struct LDKCResult_CVec_UtxoZNoneZ (*list_confirmed_utxos)(const void *this_arg); + /** + * Returns a script to use for change above dust resulting from a successful coin selection + * attempt. + */ + struct LDKCResult_ScriptNoneZ (*get_change_script)(const void *this_arg); + /** + * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within + * the transaction known to the wallet (i.e., any provided via + * [`WalletSource::list_confirmed_utxos`]). + */ + struct LDKCResult_TransactionNoneZ (*sign_tx)(const void *this_arg, struct LDKTransaction tx); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWalletSource; + + + +/** + * A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would + * avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double + * spends may happen. + */ +typedef struct MUST_USE_STRUCT LDKWallet { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeWallet *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKWallet; + + + +/** + * A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a + * [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or + * Replace-By-Fee (RBF). + * + * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction + */ +typedef struct MUST_USE_STRUCT LDKBumpTransactionEventHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBumpTransactionEventHandler *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBumpTransactionEventHandler; + + + +/** + * FilesystemPersister persists channel data on disk, where each channel's + * data is stored in a file named after its funding outpoint. + * + * Warning: this module does the best it can with calls to persist data, but it + * can only guarantee that the data is passed to the drive. It is up to the + * drive manufacturers to do the actual persistence properly, which they often + * don't (especially on consumer-grade hardware). Therefore, it is up to the + * user to validate their entire storage stack, to ensure the writes are + * persistent. + * Corollary: especially when dealing with larger amounts of money, it is best + * practice to have multiple channel data backups and not rely only on one + * FilesystemPersister. + */ +typedef struct MUST_USE_STRUCT LDKFilesystemPersister { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFilesystemPersister *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFilesystemPersister; + + + +/** + * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep + * Rust-Lightning running properly, and (2) either can or should be run in the background. Its + * responsibilities are: + * * Processing [`Event`]s with a user-provided [`EventHandler`]. + * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, + * writing it to disk/backups by invoking the callback given to it at startup. + * [`ChannelManager`] persistence should be done in the background. + * * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`] + * and [`PeerManager::timer_tick_occurred`] at the appropriate intervals. + * * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a + * [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). + * + * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied + * upon as doing so may result in high latency. + * + * # Note + * + * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then + * there is a risk of channels force-closing on startup when the manager realizes it's outdated. + * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for + * unilateral chain closure fees are at risk. + * + * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor + * [`Event`]: lightning::events::Event + * [`PeerManager::timer_tick_occurred`]: lightning::ln::peer_handler::PeerManager::timer_tick_occurred + * [`PeerManager::process_events`]: lightning::ln::peer_handler::PeerManager::process_events + *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. + */ +typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBackgroundProcessor *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBackgroundProcessor; + + + +/** + * The main Rapid Gossip Sync object. + * + * See [crate-level documentation] for usage. + * + * [crate-level documentation]: crate + */ +typedef struct MUST_USE_STRUCT LDKRapidGossipSync { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRapidGossipSync *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRapidGossipSync; + +/** + * Either [`P2PGossipSync`] or [`RapidGossipSync`]. + */ +typedef enum LDKGossipSync_Tag { + /** + * Gossip sync via the lightning peer-to-peer network as defined by BOLT 7. + */ + LDKGossipSync_P2P, + /** + * Rapid gossip sync from a trusted server. + */ + LDKGossipSync_Rapid, + /** + * No gossip sync. + */ + LDKGossipSync_None, + /** + * Must be last for serialization purposes + */ + LDKGossipSync_Sentinel, +} LDKGossipSync_Tag; + +typedef struct MUST_USE_STRUCT LDKGossipSync { + LDKGossipSync_Tag tag; + union { + struct { + /** + * Note that this field is expected to be a reference. + */ + struct LDKP2PGossipSync p2p; + }; + struct { + /** + * Note that this field is expected to be a reference. + */ + struct LDKRapidGossipSync rapid; + }; + }; +} LDKGossipSync; + + + +/** + * Data of the [`RawBolt11Invoice`] that is encoded in the data part + */ +typedef struct MUST_USE_STRUCT LDKRawDataPart { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRawDataPart *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRawDataPart; + + + +/** + * SHA-256 hash + */ +typedef struct MUST_USE_STRUCT LDKSha256 { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeSha256 *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKSha256; + + + +/** + * Positive duration that defines when (relatively to the timestamp) in the future the invoice + * expires + */ +typedef struct MUST_USE_STRUCT LDKExpiryTime { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeExpiryTime *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKExpiryTime; + + + +/** + * `min_final_cltv_expiry_delta` to use for the last HTLC in the route + */ +typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiryDelta { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMinFinalCltvExpiryDelta *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMinFinalCltvExpiryDelta; + +/** + * A 20-byte byte array. + */ +typedef struct LDKTwentyBytes { + /** + * The twenty bytes + */ + uint8_t data[20]; +} LDKTwentyBytes; + +/** + * Fallback address in case no LN payment is possible + */ +typedef enum LDKFallback_Tag { + LDKFallback_SegWitProgram, + LDKFallback_PubKeyHash, + LDKFallback_ScriptHash, + /** + * Must be last for serialization purposes + */ + LDKFallback_Sentinel, +} LDKFallback_Tag; + +typedef struct LDKFallback_LDKSegWitProgram_Body { + struct LDKWitnessVersion version; + struct LDKCVec_u8Z program; +} LDKFallback_LDKSegWitProgram_Body; + +typedef struct MUST_USE_STRUCT LDKFallback { + LDKFallback_Tag tag; + union { + LDKFallback_LDKSegWitProgram_Body seg_wit_program; + struct { + struct LDKTwentyBytes pub_key_hash; + }; + struct { + struct LDKTwentyBytes script_hash; + }; + }; +} LDKFallback; + +extern const uintptr_t MAX_BUF_SIZE; + +extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; + +extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; + +extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; + +extern const uint32_t ANTI_REORG_DELAY; + +extern const uint16_t BREAKDOWN_TIMEOUT; + +extern const uint16_t MIN_CLTV_EXPIRY_DELTA; + +extern const uint16_t MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uint16_t MAX_HTLCS; + +extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT; + +extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS; + +extern const uintptr_t MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; + +extern const uint64_t ANCHOR_INPUT_WITNESS_WEIGHT; + +extern const uint64_t HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT; + +extern const uint64_t HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; + +extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; + +extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; + +extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; + +extern const uint8_t DEFAULT_MAX_PATH_COUNT; + +extern const uint64_t MAX_TIMESTAMP; + +extern const uint64_t DEFAULT_EXPIRY_TIME; + +extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uint8_t TAG_PAYMENT_HASH; + +extern const uint8_t TAG_DESCRIPTION; + +extern const uint8_t TAG_PAYEE_PUB_KEY; + +extern const uint8_t TAG_DESCRIPTION_HASH; + +extern const uint8_t TAG_EXPIRY_TIME; + +extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY_DELTA; + +extern const uint8_t TAG_FALLBACK; + +extern const uint8_t TAG_PRIVATE_ROUTE; + +extern const uint8_t TAG_PAYMENT_SECRET; + +extern const uint8_t TAG_PAYMENT_METADATA; + +extern const uint8_t TAG_FEATURES; + +struct LDKStr _ldk_get_compiled_version(void); + +struct LDKStr _ldk_c_bindings_get_compiled_version(void); + +/** + * Gets the 128-bit integer, as 16 little-endian bytes + */ +struct LDKSixteenBytes U128_le_bytes(struct LDKU128 val); + +/** + * Constructs a new U128 from 16 little-endian bytes + */ +struct LDKU128 U128_new(struct LDKSixteenBytes le_bytes); + +/** + * Convenience function for constructing a new BigEndianScalar + */ +struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); + +/** + * Creates a new Bech32Error which has the same data as `orig` + */ +struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig); + +/** + * Releases any memory held by the given `Bech32Error` (which is currently none) + */ +void Bech32Error_free(struct LDKBech32Error o); + +/** + * Frees the data buffer, if data_is_owned is set and datalen > 0. + */ +void Transaction_free(struct LDKTransaction _res); + +/** + * Creates a new Witness which has the same data as `orig` but with a new buffer. + */ +struct LDKWitness Witness_clone(const struct LDKWitness *NONNULL_PTR orig); + +/** + * Frees the data pointed to by data + */ +void Witness_free(struct LDKWitness _res); + +/** + * Frees the witness and script_sig in a TxIn + */ +void TxIn_free(struct LDKTxIn _res); + +/** + * Convenience function for constructing a new TxIn + */ +struct LDKTxIn TxIn_new(struct LDKWitness witness, struct LDKCVec_u8Z script_sig, uint32_t sequence, struct LDKThirtyTwoBytes previous_txid, uint32_t previous_vout); + +/** + * Convenience function for constructing a new TxOut + */ +struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); + +/** + * Frees the data pointed to by script_pubkey. + */ +void TxOut_free(struct LDKTxOut _res); + +/** + * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + */ +struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); + +/** + * Frees the data buffer, if chars_is_owned is set and len > 0. + */ +void Str_free(struct LDKStr _res); + +#if defined(LDK_DEBUG_BUILD) +/** + * This function exists for memory safety testing purposes. It should never be used in production + * code + */ +const void *__unmangle_inner_ptr(const void *ptr); +#endif + +/** + * Constructs a new COption_DurationZ containing a u64 + */ +struct LDKCOption_DurationZ COption_DurationZ_some(uint64_t o); + +/** + * Constructs a new COption_DurationZ containing nothing + */ +struct LDKCOption_DurationZ COption_DurationZ_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_DurationZ_free(struct LDKCOption_DurationZ _res); + +/** + * Creates a new COption_DurationZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_DurationZ COption_DurationZ_clone(const struct LDKCOption_DurationZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_BlindedPathZ_free(struct LDKCVec_BlindedPathZ _res); + +/** + * Constructs a new COption_u64Z containing a u64 + */ +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); + +/** + * Constructs a new COption_u64Z containing nothing + */ +struct LDKCOption_u64Z COption_u64Z_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_u64Z_free(struct LDKCOption_u64Z _res); + +/** + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); + +/** + * Creates a new CResult_RefundBolt12ParseErrorZ in the success state. + */ +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_ok(struct LDKRefund o); + +/** + * Creates a new CResult_RefundBolt12ParseErrorZ in the error state. + */ +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RefundBolt12ParseErrorZ_is_ok(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RefundBolt12ParseErrorZ. + */ +void CResult_RefundBolt12ParseErrorZ_free(struct LDKCResult_RefundBolt12ParseErrorZ _res); + +/** + * Creates a new CResult_RefundBolt12ParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RefundBolt12ParseErrorZ CResult_RefundBolt12ParseErrorZ_clone(const struct LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneAPIErrorZ in the success state. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); + +/** + * Creates a new CResult_NoneAPIErrorZ in the error state. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneAPIErrorZ. + */ +void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); + +/** + * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); + +/** + * Constructs a new COption_PaymentSecretZ containing a crate::c_types::ThirtyTwoBytes + */ +struct LDKCOption_PaymentSecretZ COption_PaymentSecretZ_some(struct LDKThirtyTwoBytes o); + +/** + * Constructs a new COption_PaymentSecretZ containing nothing + */ +struct LDKCOption_PaymentSecretZ COption_PaymentSecretZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state + */ +void COption_PaymentSecretZ_free(struct LDKCOption_PaymentSecretZ _res); + +/** + * Creates a new COption_PaymentSecretZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentSecretZ COption_PaymentSecretZ_clone(const struct LDKCOption_PaymentSecretZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u8Z_free(struct LDKCVec_u8Z _res); + +/** + * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_some(struct LDKCVec_u8Z o); + +/** + * Constructs a new COption_CVec_u8ZZ containing nothing + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state + */ +void COption_CVec_u8ZZ_free(struct LDKCOption_CVec_u8ZZ _res); + +/** + * Creates a new COption_CVec_u8ZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_clone(const struct LDKCOption_CVec_u8ZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_ok(struct LDKRecipientOnionFields o); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. + */ +void CResult_RecipientOnionFieldsDecodeErrorZ_free(struct LDKCResult_RecipientOnionFieldsDecodeErrorZ _res); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_clone(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); + +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. + */ +void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); + +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. + */ +void CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res); + +/** + * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKStaticPaymentOutputDescriptor o); + +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. + */ +void CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res); + +/** + * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); + +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + */ +void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); + +/** + * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); + +/** + * Constructs a new COption_PackedLockTimeZ containing a u32 + */ +struct LDKCOption_PackedLockTimeZ COption_PackedLockTimeZ_some(uint32_t o); + +/** + * Constructs a new COption_PackedLockTimeZ containing nothing + */ +struct LDKCOption_PackedLockTimeZ COption_PackedLockTimeZ_none(void); + +/** + * Frees any resources associated with the u32, if we are in the Some state + */ +void COption_PackedLockTimeZ_free(struct LDKCOption_PackedLockTimeZ _res); + +/** + * Creates a new COption_PackedLockTimeZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PackedLockTimeZ COption_PackedLockTimeZ_clone(const struct LDKCOption_PackedLockTimeZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_PartiallySignedTransactionusizeZ C2Tuple_PartiallySignedTransactionusizeZ_clone(const struct LDKC2Tuple_PartiallySignedTransactionusizeZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_PartiallySignedTransactionusizeZ from the contained elements. + */ +struct LDKC2Tuple_PartiallySignedTransactionusizeZ C2Tuple_PartiallySignedTransactionusizeZ_new(struct LDKCVec_u8Z a, uintptr_t b); + +/** + * Frees any resources used by the C2Tuple_PartiallySignedTransactionusizeZ. + */ +void C2Tuple_PartiallySignedTransactionusizeZ_free(struct LDKC2Tuple_PartiallySignedTransactionusizeZ _res); + +/** + * Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_ok(struct LDKC2Tuple_PartiallySignedTransactionusizeZ o); + +/** + * Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ. + */ +void CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_free(struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_clone(const struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); + +/** + * Creates a new CResult_NoneNoneZ in the success state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); + +/** + * Creates a new CResult_NoneNoneZ in the error state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneNoneZ. + */ +void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); + +/** + * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); + +/** + * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + */ +void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + */ +void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SignatureNoneZ in the success state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); + +/** + * Creates a new CResult_SignatureNoneZ in the error state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SignatureNoneZ. + */ +void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); + +/** + * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PublicKeyNoneZ in the success state. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyNoneZ in the error state. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeyNoneZ. + */ +void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); + +/** + * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar + */ +struct LDKCOption_ScalarZ COption_ScalarZ_some(struct LDKBigEndianScalar o); + +/** + * Constructs a new COption_ScalarZ containing nothing + */ +struct LDKCOption_ScalarZ COption_ScalarZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state + */ +void COption_ScalarZ_free(struct LDKCOption_ScalarZ _res); + +/** + * Creates a new COption_ScalarZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_ScalarZ COption_ScalarZ_clone(const struct LDKCOption_ScalarZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SharedSecretNoneZ in the success state. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_SharedSecretNoneZ in the error state. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SharedSecretNoneZ_is_ok(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SharedSecretNoneZ. + */ +void CResult_SharedSecretNoneZ_free(struct LDKCResult_SharedSecretNoneZ _res); + +/** + * Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_clone(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_U5Z_free(struct LDKCVec_U5Z _res); + +/** + * Creates a new CResult_RecoverableSignatureNoneZ in the success state. + */ +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_ok(struct LDKRecoverableSignature o); + +/** + * Creates a new CResult_RecoverableSignatureNoneZ in the error state. + */ +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RecoverableSignatureNoneZ. + */ +void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatureNoneZ _res); + +/** + * Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. + */ +struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(struct LDKWriteableEcdsaChannelSigner o); + +/** + * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. + */ +struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. + */ +void CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res); + +/** + * Creates a new CResult_ScriptNoneZ in the success state. + */ +struct LDKCResult_ScriptNoneZ CResult_ScriptNoneZ_ok(struct LDKCVec_u8Z o); + +/** + * Creates a new CResult_ScriptNoneZ in the error state. + */ +struct LDKCResult_ScriptNoneZ CResult_ScriptNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ScriptNoneZ_is_ok(const struct LDKCResult_ScriptNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ScriptNoneZ. + */ +void CResult_ScriptNoneZ_free(struct LDKCResult_ScriptNoneZ _res); + +/** + * Creates a new CResult_ScriptNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ScriptNoneZ CResult_ScriptNoneZ_clone(const struct LDKCResult_ScriptNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ShutdownScriptNoneZ in the success state. + */ +struct LDKCResult_ShutdownScriptNoneZ CResult_ShutdownScriptNoneZ_ok(struct LDKShutdownScript o); + +/** + * Creates a new CResult_ShutdownScriptNoneZ in the error state. + */ +struct LDKCResult_ShutdownScriptNoneZ CResult_ShutdownScriptNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ShutdownScriptNoneZ_is_ok(const struct LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ShutdownScriptNoneZ. + */ +void CResult_ShutdownScriptNoneZ_free(struct LDKCResult_ShutdownScriptNoneZ _res); + +/** + * Creates a new CResult_ShutdownScriptNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ShutdownScriptNoneZ CResult_ShutdownScriptNoneZ_clone(const struct LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + */ +void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); + +/** + * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + */ +void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); + +/** + * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PartiallySignedTransactionNoneZ in the success state. + */ +struct LDKCResult_PartiallySignedTransactionNoneZ CResult_PartiallySignedTransactionNoneZ_ok(struct LDKCVec_u8Z o); + +/** + * Creates a new CResult_PartiallySignedTransactionNoneZ in the error state. + */ +struct LDKCResult_PartiallySignedTransactionNoneZ CResult_PartiallySignedTransactionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PartiallySignedTransactionNoneZ_is_ok(const struct LDKCResult_PartiallySignedTransactionNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PartiallySignedTransactionNoneZ. + */ +void CResult_PartiallySignedTransactionNoneZ_free(struct LDKCResult_PartiallySignedTransactionNoneZ _res); + +/** + * Creates a new CResult_PartiallySignedTransactionNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PartiallySignedTransactionNoneZ CResult_PartiallySignedTransactionNoneZ_clone(const struct LDKCResult_PartiallySignedTransactionNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TransactionNoneZ in the success state. + */ +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); + +/** + * Creates a new CResult_TransactionNoneZ in the error state. + */ +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_TransactionNoneZ. + */ +void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); + +/** + * Creates a new CResult_TransactionNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore + */ +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); + +/** + * Constructs a new COption_WriteableScoreZ containing nothing + */ +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state + */ +void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); + +/** + * Creates a new CResult_NoneErrorZ in the success state. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); + +/** + * Creates a new CResult_NoneErrorZ in the error state. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneErrorZ. + */ +void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); + +/** + * Creates a new CResult_NoneErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ in the success state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); + +/** + * Creates a new CResult_RouteLightningErrorZ in the error state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteLightningErrorZ_is_ok(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteLightningErrorZ. + */ +void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_ok(struct LDKInFlightHtlcs o); + +/** + * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InFlightHtlcsDecodeErrorZ_is_ok(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. + */ +void CResult_InFlightHtlcsDecodeErrorZ_free(struct LDKCResult_InFlightHtlcsDecodeErrorZ _res); + +/** + * Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_clone(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_ok(struct LDKRouteHop o); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteHopDecodeErrorZ. + */ +void CResult_RouteHopDecodeErrorZ_free(struct LDKCResult_RouteHopDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_clone(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_BlindedHopZ_free(struct LDKCVec_BlindedHopZ _res); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_ok(struct LDKBlindedTail o); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedTailDecodeErrorZ_is_ok(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedTailDecodeErrorZ. + */ +void CResult_BlindedTailDecodeErrorZ_free(struct LDKCResult_BlindedTailDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_clone(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); + +/** + * Constructs a new COption_u32Z containing a u32 + */ +struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); + +/** + * Constructs a new COption_u32Z containing nothing + */ +struct LDKCOption_u32Z COption_u32Z_none(void); + +/** + * Frees any resources associated with the u32, if we are in the Some state + */ +void COption_u32Z_free(struct LDKCOption_u32Z _res); + +/** + * Creates a new COption_u32Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PathZ_free(struct LDKCVec_PathZ _res); + +/** + * Creates a new CResult_RouteDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); + +/** + * Creates a new CResult_RouteDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteDecodeErrorZ_is_ok(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteDecodeErrorZ. + */ +void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteParametersDecodeErrorZ_is_ok(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteParametersDecodeErrorZ. + */ +void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u64Z_free(struct LDKCVec_u64Z _res); + +/** + * Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_ok(struct LDKPaymentParameters o); + +/** + * Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentParametersDecodeErrorZ_is_ok(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. + */ +void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_clone(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_clone(const struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. + */ +struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_new(struct LDKBlindedPayInfo a, struct LDKBlindedPath b); + +/** + * Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. + */ +void C2Tuple_BlindedPayInfoBlindedPathZ_free(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHintDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteHintDecodeErrorZ. + */ +void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHintHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. + */ +void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. + */ +void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_clone(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_NodeIdZ_free(struct LDKCVec_NodeIdZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const struct LDKC2Tuple_u64u64Z *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_u64u64Z from the contained elements. + */ +struct LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b); + +/** + * Frees any resources used by the C2Tuple_u64u64Z. + */ +void C2Tuple_u64u64Z_free(struct LDKC2Tuple_u64u64Z _res); + +/** + * Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_some(struct LDKC2Tuple_u64u64Z o); + +/** + * Constructs a new COption_C2Tuple_u64u64ZZ containing nothing + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state + */ +void COption_C2Tuple_u64u64ZZ_free(struct LDKCOption_C2Tuple_u64u64ZZ _res); + +/** + * Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_clone(const struct LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_Z C2Tuple_Z_clone(const struct LDKC2Tuple_Z *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_Z from the contained elements. + */ +struct LDKC2Tuple_Z C2Tuple_Z_new(struct LDKEightU16s a, struct LDKEightU16s b); + +/** + * Frees any resources used by the C2Tuple_Z. + */ +void C2Tuple_Z_free(struct LDKC2Tuple_Z _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple__u168_u168Z C2Tuple__u168_u168Z_clone(const struct LDKC2Tuple__u168_u168Z *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple__u168_u168Z from the contained elements. + */ +struct LDKC2Tuple__u168_u168Z C2Tuple__u168_u168Z_new(struct LDKEightU16s a, struct LDKEightU16s b); + +/** + * Frees any resources used by the C2Tuple__u168_u168Z. + */ +void C2Tuple__u168_u168Z_free(struct LDKC2Tuple__u168_u168Z _res); + +/** + * Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z + */ +struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_some(struct LDKC2Tuple__u168_u168Z o); + +/** + * Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing + */ +struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state + */ +void COption_C2Tuple_EightU16sEightU16sZZ_free(struct LDKCOption_C2Tuple_EightU16sEightU16sZZ _res); + +/** + * Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_clone(const struct LDKCOption_C2Tuple_EightU16sEightU16sZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. + */ +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o); + +/** + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. + */ +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. + */ +void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_clone(const struct LDKC2Tuple_usizeTransactionZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + */ +struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); + +/** + * Frees any resources used by the C2Tuple_usizeTransactionZ. + */ +void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); + +/** + * Constructs a new COption_BlockHashZ containing a crate::c_types::ThirtyTwoBytes + */ +struct LDKCOption_BlockHashZ COption_BlockHashZ_some(struct LDKThirtyTwoBytes o); + +/** + * Constructs a new COption_BlockHashZ containing nothing + */ +struct LDKCOption_BlockHashZ COption_BlockHashZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state + */ +void COption_BlockHashZ_free(struct LDKCOption_BlockHashZ _res); + +/** + * Creates a new COption_BlockHashZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_BlockHashZ COption_BlockHashZ_clone(const struct LDKCOption_BlockHashZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_TxidCOption_BlockHashZZ C2Tuple_TxidCOption_BlockHashZZ_clone(const struct LDKC2Tuple_TxidCOption_BlockHashZZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_TxidCOption_BlockHashZZ from the contained elements. + */ +struct LDKC2Tuple_TxidCOption_BlockHashZZ C2Tuple_TxidCOption_BlockHashZZ_new(struct LDKThirtyTwoBytes a, struct LDKCOption_BlockHashZ b); + +/** + * Frees any resources used by the C2Tuple_TxidCOption_BlockHashZZ. + */ +void C2Tuple_TxidCOption_BlockHashZZ_free(struct LDKC2Tuple_TxidCOption_BlockHashZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_TxidCOption_BlockHashZZZ_free(struct LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(const struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. + */ +struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorEventZ b, struct LDKPublicKey c); + +/** + * Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. + */ +void C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res); + +/** + * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); + +/** + * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InitFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + */ +void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_clone(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + */ +void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + */ +void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_clone(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(struct LDKBolt11InvoiceFeatures o); + +/** + * Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt11InvoiceFeaturesDecodeErrorZ. + */ +void CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(const struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(struct LDKBolt12InvoiceFeatures o); + +/** + * Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt12InvoiceFeaturesDecodeErrorZ. + */ +void CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(const struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_ok(struct LDKBlindedHopFeatures o); + +/** + * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. + */ +void CResult_BlindedHopFeaturesDecodeErrorZ_free(struct LDKCResult_BlindedHopFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_clone(const struct LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. + */ +void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChainHashZ_free(struct LDKCVec_ChainHashZ _res); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ in the success state. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_ok(struct LDKOffer o); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ in the error state. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferBolt12ParseErrorZ_is_ok(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferBolt12ParseErrorZ. + */ +void CResult_OfferBolt12ParseErrorZ_free(struct LDKCResult_OfferBolt12ParseErrorZ _res); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_clone(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PublicKeyErrorZ in the success state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyErrorZ in the error state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeyErrorZ. + */ +void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); + +/** + * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_ok(struct LDKNodeId o); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeIdDecodeErrorZ_is_ok(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeIdDecodeErrorZ. + */ +void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); + +/** + * Constructs a new COption_NetworkUpdateZ containing nothing + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state + */ +void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); + +/** + * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_ok(struct LDKCOption_NetworkUpdateZ o); + +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. + */ +void CResult_COption_NetworkUpdateZDecodeErrorZ_free(struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_clone(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_UtxoLookupZ containing a crate::lightning::routing::utxo::UtxoLookup + */ +struct LDKCOption_UtxoLookupZ COption_UtxoLookupZ_some(struct LDKUtxoLookup o); + +/** + * Constructs a new COption_UtxoLookupZ containing nothing + */ +struct LDKCOption_UtxoLookupZ COption_UtxoLookupZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state + */ +void COption_UtxoLookupZ_free(struct LDKCOption_UtxoLookupZ _res); + +/** + * Creates a new CResult_NoneLightningErrorZ in the success state. + */ +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); + +/** + * Creates a new CResult_NoneLightningErrorZ in the error state. + */ +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneLightningErrorZ_is_ok(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneLightningErrorZ. + */ +void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); + +/** + * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_boolLightningErrorZ in the success state. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); + +/** + * Creates a new CResult_boolLightningErrorZ in the error state. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_boolLightningErrorZ_is_ok(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_boolLightningErrorZ. + */ +void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); + +/** + * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + */ +struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); + +/** + * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + */ +void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); + +/** + * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o); + +/** + * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state + */ +void COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); + +/** + * Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); + +/** + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_ok(struct LDKChannelUpdateInfo o); + +/** + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. + */ +void CResult_ChannelUpdateInfoDecodeErrorZ_free(struct LDKCResult_ChannelUpdateInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. + */ +void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + */ +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + */ +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RoutingFeesDecodeErrorZ_is_ok(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. + */ +void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); + +/** + * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. + */ +void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_ok(struct LDKNodeAlias o); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeAliasDecodeErrorZ_is_ok(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeAliasDecodeErrorZ. + */ +void CResult_NodeAliasDecodeErrorZ_free(struct LDKCResult_NodeAliasDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeAliasDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_clone(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + */ +void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + */ +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); + +/** + * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + */ +struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NetworkGraphDecodeErrorZ_is_ok(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. + */ +void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); + +/** + * Constructs a new COption_CVec_NetAddressZZ containing a crate::c_types::derived::CVec_NetAddressZ + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_some(struct LDKCVec_NetAddressZ o); + +/** + * Constructs a new COption_CVec_NetAddressZZ containing nothing + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::CVec_NetAddressZ, if we are in the Some state + */ +void COption_CVec_NetAddressZZ_free(struct LDKCOption_CVec_NetAddressZZ _res); + +/** + * Creates a new COption_CVec_NetAddressZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_clone(const struct LDKCOption_CVec_NetAddressZZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_PaymentPreimageZ containing a crate::c_types::ThirtyTwoBytes + */ +struct LDKCOption_PaymentPreimageZ COption_PaymentPreimageZ_some(struct LDKThirtyTwoBytes o); + +/** + * Constructs a new COption_PaymentPreimageZ containing nothing + */ +struct LDKCOption_PaymentPreimageZ COption_PaymentPreimageZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state + */ +void COption_PaymentPreimageZ_free(struct LDKCOption_PaymentPreimageZ _res); + +/** + * Creates a new COption_PaymentPreimageZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentPreimageZ COption_PaymentPreimageZ_clone(const struct LDKCOption_PaymentPreimageZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_HTLCOutputInCommitmentZ_free(struct LDKCVec_HTLCOutputInCommitmentZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_HTLCDescriptorZ_free(struct LDKCVec_HTLCDescriptorZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_UtxoZ_free(struct LDKCVec_UtxoZ _res); + +/** + * Constructs a new COption_TxOutZ containing a crate::c_types::TxOut + */ +struct LDKCOption_TxOutZ COption_TxOutZ_some(struct LDKTxOut o); + +/** + * Constructs a new COption_TxOutZ containing nothing + */ +struct LDKCOption_TxOutZ COption_TxOutZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::TxOut, if we are in the Some state + */ +void COption_TxOutZ_free(struct LDKCOption_TxOutZ _res); + +/** + * Creates a new COption_TxOutZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_TxOutZ COption_TxOutZ_clone(const struct LDKCOption_TxOutZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_InputZ_free(struct LDKCVec_InputZ _res); + +/** + * Creates a new CResult_CoinSelectionNoneZ in the success state. + */ +struct LDKCResult_CoinSelectionNoneZ CResult_CoinSelectionNoneZ_ok(struct LDKCoinSelection o); + +/** + * Creates a new CResult_CoinSelectionNoneZ in the error state. + */ +struct LDKCResult_CoinSelectionNoneZ CResult_CoinSelectionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CoinSelectionNoneZ_is_ok(const struct LDKCResult_CoinSelectionNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CoinSelectionNoneZ. + */ +void CResult_CoinSelectionNoneZ_free(struct LDKCResult_CoinSelectionNoneZ _res); + +/** + * Creates a new CResult_CoinSelectionNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CoinSelectionNoneZ CResult_CoinSelectionNoneZ_clone(const struct LDKCResult_CoinSelectionNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CVec_UtxoZNoneZ in the success state. + */ +struct LDKCResult_CVec_UtxoZNoneZ CResult_CVec_UtxoZNoneZ_ok(struct LDKCVec_UtxoZ o); + +/** + * Creates a new CResult_CVec_UtxoZNoneZ in the error state. + */ +struct LDKCResult_CVec_UtxoZNoneZ CResult_CVec_UtxoZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_UtxoZNoneZ_is_ok(const struct LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CVec_UtxoZNoneZ. + */ +void CResult_CVec_UtxoZNoneZ_free(struct LDKCResult_CVec_UtxoZNoneZ _res); + +/** + * Creates a new CResult_CVec_UtxoZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_UtxoZNoneZ CResult_CVec_UtxoZNoneZ_clone(const struct LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_u16Z containing a u16 + */ +struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); + +/** + * Constructs a new COption_u16Z containing nothing + */ +struct LDKCOption_u16Z COption_u16Z_none(void); + +/** + * Frees any resources associated with the u16, if we are in the Some state + */ +void COption_u16Z_free(struct LDKCOption_u16Z _res); + +/** + * Creates a new COption_u16Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); + +/** + * Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channelmanager::ChannelShutdownState + */ +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_some(enum LDKChannelShutdownState o); + +/** + * Constructs a new COption_ChannelShutdownStateZ containing nothing + */ +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::ln::channelmanager::ChannelShutdownState, if we are in the Some state + */ +void COption_ChannelShutdownStateZ_free(struct LDKCOption_ChannelShutdownStateZ _res); + +/** + * Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_clone(const struct LDKCOption_ChannelShutdownStateZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_PaymentHashZ containing a crate::c_types::ThirtyTwoBytes + */ +struct LDKCOption_PaymentHashZ COption_PaymentHashZ_some(struct LDKThirtyTwoBytes o); + +/** + * Constructs a new COption_PaymentHashZ containing nothing + */ +struct LDKCOption_PaymentHashZ COption_PaymentHashZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state + */ +void COption_PaymentHashZ_free(struct LDKCOption_PaymentHashZ _res); + +/** + * Creates a new COption_PaymentHashZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentHashZ COption_PaymentHashZ_clone(const struct LDKCOption_PaymentHashZ *NONNULL_PTR orig); + +/** + * Creates a new CResult__u832APIErrorZ in the success state. + */ +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult__u832APIErrorZ in the error state. + */ +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult__u832APIErrorZ. + */ +void CResult__u832APIErrorZ_free(struct LDKCResult__u832APIErrorZ _res); + +/** + * Creates a new CResult__u832APIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_clone(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RecentPaymentDetailsZ_free(struct LDKCVec_RecentPaymentDetailsZ _res); + +/** + * Creates a new CResult_NonePaymentSendFailureZ in the success state. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); + +/** + * Creates a new CResult_NonePaymentSendFailureZ in the error state. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NonePaymentSendFailureZ. + */ +void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); + +/** + * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneRetryableSendFailureZ in the success state. + */ +struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_ok(void); + +/** + * Creates a new CResult_NoneRetryableSendFailureZ in the error state. + */ +struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_err(enum LDKRetryableSendFailure e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneRetryableSendFailureZ_is_ok(const struct LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneRetryableSendFailureZ. + */ +void CResult_NoneRetryableSendFailureZ_free(struct LDKCResult_NoneRetryableSendFailureZ _res); + +/** + * Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_clone(const struct LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. + */ +struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. + */ +struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentHashPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. + */ +void CResult_PaymentHashPaymentSendFailureZ_free(struct LDKCResult_PaymentHashPaymentSendFailureZ _res); + +/** + * Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_clone(const struct LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. + */ +struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. + */ +struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_err(enum LDKRetryableSendFailure e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentHashRetryableSendFailureZ_is_ok(const struct LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. + */ +void CResult_PaymentHashRetryableSendFailureZ_free(struct LDKCResult_PaymentHashRetryableSendFailureZ _res); + +/** + * Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_clone(const struct LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_clone(const struct LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. + */ +struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); + +/** + * Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. + */ +void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(struct LDKC2Tuple_PaymentHashPaymentIdZ o); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. + */ +void CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ThirtyTwoBytesZ_free(struct LDKCVec_ThirtyTwoBytesZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_clone(const struct LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. + */ +struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); + +/** + * Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. + */ +void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. + */ +void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentSecretNoneZ in the success state. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentSecretNoneZ in the error state. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentSecretNoneZ. + */ +void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res); + +/** + * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_clone(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. + */ +void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res); + +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_CVec_ChainHashZZ containing a crate::c_types::derived::CVec_ChainHashZ + */ +struct LDKCOption_CVec_ChainHashZZ COption_CVec_ChainHashZZ_some(struct LDKCVec_ChainHashZ o); + +/** + * Constructs a new COption_CVec_ChainHashZZ containing nothing + */ +struct LDKCOption_CVec_ChainHashZZ COption_CVec_ChainHashZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::CVec_ChainHashZ, if we are in the Some state + */ +void COption_CVec_ChainHashZZ_free(struct LDKCOption_CVec_ChainHashZZ _res); + +/** + * Creates a new COption_CVec_ChainHashZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_ChainHashZZ COption_CVec_ChainHashZZ_clone(const struct LDKCOption_CVec_ChainHashZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + */ +void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + */ +void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + */ +void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. + */ +void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_clone(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_ok(enum LDKChannelShutdownState o); + +/** + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelShutdownStateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. + */ +void CResult_ChannelShutdownStateDecodeErrorZ_free(struct LDKCResult_ChannelShutdownStateDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_clone(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); /** - * The contents of an onion message. In the context of offers, this would be the invoice, invoice - * request, or invoice error. + * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. */ -typedef enum LDKOnionMessageContents_Tag { - /** - * A custom onion message specified by the user. - */ - LDKOnionMessageContents_Custom, - /** - * Must be last for serialization purposes - */ - LDKOnionMessageContents_Sentinel, -} LDKOnionMessageContents_Tag; +struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); -typedef struct MUST_USE_STRUCT LDKOnionMessageContents { - LDKOnionMessageContents_Tag tag; - union { - struct { - struct LDKCustomOnionMessageContents custom; - }; - }; -} LDKOnionMessageContents; +/** + * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + */ +void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); +/** + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + */ +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); +/** + * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + */ +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); /** - * FilesystemPersister persists channel data on disk, where each channel's - * data is stored in a file named after its funding outpoint. - * - * Warning: this module does the best it can with calls to persist data, but it - * can only guarantee that the data is passed to the drive. It is up to the - * drive manufacturers to do the actual persistence properly, which they often - * don't (especially on consumer-grade hardware). Therefore, it is up to the - * user to validate their entire storage stack, to ensure the writes are - * persistent. - * Corollary: especially when dealing with larger amounts of money, it is best - * practice to have multiple channel data backups and not rely only on one - * FilesystemPersister. + * Checks if the given object is currently in the success state */ -typedef struct MUST_USE_STRUCT LDKFilesystemPersister { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeFilesystemPersister *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKFilesystemPersister; +bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o); +/** + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + */ +void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); +/** + * Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the success state. + */ +struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ CResult_MaxDustHTLCExposureDecodeErrorZ_ok(struct LDKMaxDustHTLCExposure o); /** - * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep - * Rust-Lightning running properly, and (2) either can or should be run in the background. Its - * responsibilities are: - * * Processing [`Event`]s with a user-provided [`EventHandler`]. - * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, - * writing it to disk/backups by invoking the callback given to it at startup. - * [`ChannelManager`] persistence should be done in the background. - * * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`] - * and [`PeerManager::timer_tick_occurred`] at the appropriate intervals. - * * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a - * [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). - * - * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied - * upon as doing so may result in high latency. - * - * # Note - * - * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then - * there is a risk of channels force-closing on startup when the manager realizes it's outdated. - * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for - * unilateral chain closure fees are at risk. - * - * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor - * [`Event`]: lightning::events::Event - *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. + * Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the error state. */ -typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeBackgroundProcessor *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKBackgroundProcessor; +struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ CResult_MaxDustHTLCExposureDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(const struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR o); +/** + * Frees any resources used by the CResult_MaxDustHTLCExposureDecodeErrorZ. + */ +void CResult_MaxDustHTLCExposureDecodeErrorZ_free(struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ _res); /** - * The main Rapid Gossip Sync object. - * - * See [crate-level documentation] for usage. - * - * [crate-level documentation]: crate + * Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -typedef struct MUST_USE_STRUCT LDKRapidGossipSync { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRapidGossipSync *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRapidGossipSync; +struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ CResult_MaxDustHTLCExposureDecodeErrorZ_clone(const struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR orig); /** - * Either [`P2PGossipSync`] or [`RapidGossipSync`]. + * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. */ -typedef enum LDKGossipSync_Tag { - /** - * Gossip sync via the lightning peer-to-peer network as defined by BOLT 7. - */ - LDKGossipSync_P2P, - /** - * Rapid gossip sync from a trusted server. - */ - LDKGossipSync_Rapid, - /** - * No gossip sync. - */ - LDKGossipSync_None, - /** - * Must be last for serialization purposes - */ - LDKGossipSync_Sentinel, -} LDKGossipSync_Tag; +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); -typedef struct MUST_USE_STRUCT LDKGossipSync { - LDKGossipSync_Tag tag; - union { - struct { - /** - * Note that this field is expected to be a reference. - */ - struct LDKP2PGossipSync p2p; - }; - struct { - /** - * Note that this field is expected to be a reference. - */ - struct LDKRapidGossipSync rapid; - }; - }; -} LDKGossipSync; +/** + * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelConfigDecodeErrorZ_is_ok(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR o); +/** + * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + */ +void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); /** - * Data of the [`RawInvoice`] that is encoded in the data part + * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -typedef struct MUST_USE_STRUCT LDKRawDataPart { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRawDataPart *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRawDataPart; +struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); +/** + * Constructs a new COption_MaxDustHTLCExposureZ containing a crate::lightning::util::config::MaxDustHTLCExposure + */ +struct LDKCOption_MaxDustHTLCExposureZ COption_MaxDustHTLCExposureZ_some(struct LDKMaxDustHTLCExposure o); +/** + * Constructs a new COption_MaxDustHTLCExposureZ containing nothing + */ +struct LDKCOption_MaxDustHTLCExposureZ COption_MaxDustHTLCExposureZ_none(void); /** - * SHA-256 hash + * Frees any resources associated with the crate::lightning::util::config::MaxDustHTLCExposure, if we are in the Some state */ -typedef struct MUST_USE_STRUCT LDKSha256 { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeSha256 *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKSha256; +void COption_MaxDustHTLCExposureZ_free(struct LDKCOption_MaxDustHTLCExposureZ _res); + +/** + * Creates a new COption_MaxDustHTLCExposureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_MaxDustHTLCExposureZ COption_MaxDustHTLCExposureZ_clone(const struct LDKCOption_MaxDustHTLCExposureZ *NONNULL_PTR orig); +/** + * Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError + */ +struct LDKCOption_APIErrorZ COption_APIErrorZ_some(struct LDKAPIError o); +/** + * Constructs a new COption_APIErrorZ containing nothing + */ +struct LDKCOption_APIErrorZ COption_APIErrorZ_none(void); /** - * Positive duration that defines when (relatively to the timestamp) in the future the invoice - * expires + * Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state */ -typedef struct MUST_USE_STRUCT LDKExpiryTime { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeExpiryTime *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKExpiryTime; +void COption_APIErrorZ_free(struct LDKCOption_APIErrorZ _res); + +/** + * Creates a new COption_APIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_APIErrorZ COption_APIErrorZ_clone(const struct LDKCOption_APIErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_ok(struct LDKCOption_APIErrorZ o); +/** + * Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_err(struct LDKDecodeError e); /** - * `min_final_cltv_expiry_delta` to use for the last HTLC in the route + * Checks if the given object is currently in the success state */ -typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiryDelta { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeMinFinalCltvExpiryDelta *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKMinFinalCltvExpiryDelta; +bool CResult_COption_APIErrorZDecodeErrorZ_is_ok(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR o); /** - * A 20-byte byte array. + * Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. */ -typedef struct LDKTwentyBytes { - /** - * The twenty bytes - */ - uint8_t data[20]; -} LDKTwentyBytes; +void CResult_COption_APIErrorZDecodeErrorZ_free(struct LDKCResult_COption_APIErrorZDecodeErrorZ _res); /** - * Fallback address in case no LN payment is possible + * Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -typedef enum LDKFallback_Tag { - LDKFallback_SegWitProgram, - LDKFallback_PubKeyHash, - LDKFallback_ScriptHash, - /** - * Must be last for serialization purposes - */ - LDKFallback_Sentinel, -} LDKFallback_Tag; +struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_clone(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR orig); -typedef struct LDKFallback_LDKSegWitProgram_Body { - struct LDKWitnessVersion version; - struct LDKCVec_u8Z program; -} LDKFallback_LDKSegWitProgram_Body; +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); -typedef struct MUST_USE_STRUCT LDKFallback { - LDKFallback_Tag tag; - union { - LDKFallback_LDKSegWitProgram_Body seg_wit_program; - struct { - struct LDKTwentyBytes pub_key_hash; - }; - struct { - struct LDKTwentyBytes script_hash; - }; - }; -} LDKFallback; +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); -extern const uintptr_t MAX_BUF_SIZE; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o); -extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; +/** + * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. + */ +void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); -extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; +/** + * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); -extern const uint64_t CLOSED_CHANNEL_UPDATE_ID; +/** + * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent + */ +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o); -extern const uint32_t ANTI_REORG_DELAY; +/** + * Constructs a new COption_MonitorEventZ containing nothing + */ +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void); -extern const uint16_t BREAKDOWN_TIMEOUT; +/** + * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state + */ +void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res); -extern const uint16_t MIN_CLTV_EXPIRY_DELTA; +/** + * Creates a new COption_MonitorEventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig); -extern const uint16_t MIN_FINAL_CLTV_EXPIRY_DELTA; +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o); -extern const uint16_t MAX_HTLCS; +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_err(struct LDKDecodeError e); -extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_MonitorEventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR o); -extern const uintptr_t OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS; +/** + * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. + */ +void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res); -extern const uintptr_t MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig); -extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); -extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); -extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o); -extern const uint8_t DEFAULT_MAX_PATH_COUNT; +/** + * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + */ +void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); -extern const uint64_t MAX_TIMESTAMP; +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); -extern const uint64_t DEFAULT_EXPIRY_TIME; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); -extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; +/** + * Creates a new C2Tuple_OutPointScriptZ from the contained elements. + */ +struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); -extern const uint8_t TAG_PAYMENT_HASH; +/** + * Frees any resources used by the C2Tuple_OutPointScriptZ. + */ +void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); -extern const uint8_t TAG_DESCRIPTION; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); -extern const uint8_t TAG_PAYEE_PUB_KEY; +/** + * Creates a new C2Tuple_u32ScriptZ from the contained elements. + */ +struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); -extern const uint8_t TAG_DESCRIPTION_HASH; +/** + * Frees any resources used by the C2Tuple_u32ScriptZ. + */ +void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); -extern const uint8_t TAG_EXPIRY_TIME; +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); -extern const uint8_t TAG_MIN_FINAL_CLTV_EXPIRY_DELTA; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR orig); -extern const uint8_t TAG_FALLBACK; +/** + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. + */ +struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); -extern const uint8_t TAG_PRIVATE_ROUTE; +/** + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. + */ +void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); -extern const uint8_t TAG_PAYMENT_SECRET; +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); -extern const uint8_t TAG_PAYMENT_METADATA; +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); -extern const uint8_t TAG_FEATURES; +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); -struct LDKStr _ldk_get_compiled_version(void); +/** + * Creates a new C2Tuple_u32TxOutZ from the contained elements. + */ +struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); -struct LDKStr _ldk_c_bindings_get_compiled_version(void); +/** + * Frees any resources used by the C2Tuple_u32TxOutZ. + */ +void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); /** - * Gets the 128-bit integer, as 16 little-endian bytes + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKSixteenBytes U128_le_bytes(struct LDKU128 val); +void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); /** - * Constructs a new U128 from 16 little-endian bytes + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKU128 U128_new(struct LDKSixteenBytes le_bytes); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR orig); /** - * Convenience function for constructing a new BigEndianScalar + * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. */ -struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); +struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); /** - * Creates a new Bech32Error which has the same data as `orig` + * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. */ -struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig); +void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); /** - * Releases any memory held by the given `Bech32Error` (which is currently none) + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void Bech32Error_free(struct LDKBech32Error o); +void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); /** - * Frees the data buffer, if data_is_owned is set and datalen > 0. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void Transaction_free(struct LDKTransaction _res); +void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); /** - * Frees the data pointed to by data + * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. */ -void Witness_free(struct LDKWitness _res); +struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); /** - * Convenience function for constructing a new TxOut + * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. */ -struct LDKTxOut TxOut_new(struct LDKCVec_u8Z script_pubkey, uint64_t value); +void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); /** - * Frees the data pointed to by script_pubkey. + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. */ -void TxOut_free(struct LDKTxOut _res); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); /** - * Creates a new TxOut which has the same data as `orig` but with a new script buffer. + * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. */ -struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the data buffer, if chars_is_owned is set and len > 0. + * Checks if the given object is currently in the success state */ -void Str_free(struct LDKStr _res); +bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o); -#if defined(LDK_DEBUG_BUILD) /** - * This function exists for memory safety testing purposes. It should never be used in production - * code + * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. */ -const void *__unmangle_inner_ptr(const void *ptr); -#endif +void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); /** - * Constructs a new COption_DurationZ containing a u64 + * Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. */ -struct LDKCOption_DurationZ COption_DurationZ_some(uint64_t o); +struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); /** - * Constructs a new COption_DurationZ containing nothing + * Frees any resources used by the C2Tuple_PublicKeyTypeZ. */ -struct LDKCOption_DurationZ COption_DurationZ_none(void); +void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); /** - * Frees any resources associated with the u64, if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_DurationZ_free(struct LDKCOption_DurationZ _res); +void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); /** - * Creates a new COption_DurationZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage */ -struct LDKCOption_DurationZ COption_DurationZ_clone(const struct LDKCOption_DurationZ *NONNULL_PTR orig); +struct LDKCOption_OffersMessageZ COption_OffersMessageZ_some(struct LDKOffersMessage o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_OffersMessageZ containing nothing */ -void CVec_BlindedPathZ_free(struct LDKCVec_BlindedPathZ _res); +struct LDKCOption_OffersMessageZ COption_OffersMessageZ_none(void); /** - * Constructs a new COption_u64Z containing a u64 + * Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); +void COption_OffersMessageZ_free(struct LDKCOption_OffersMessageZ _res); /** - * Constructs a new COption_u64Z containing nothing + * Creates a new COption_OffersMessageZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u64Z COption_u64Z_none(void); +struct LDKCOption_OffersMessageZ COption_OffersMessageZ_clone(const struct LDKCOption_OffersMessageZ *NONNULL_PTR orig); /** - * Frees any resources associated with the u64, if we are in the Some state + * Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_some(struct LDKCustomOnionMessageContents o); /** - * Creates a new COption_u64Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_CustomOnionMessageContentsZ containing nothing */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); +struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_none(void); /** - * Creates a new CResult_NoneAPIErrorZ in the success state. + * Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); +void COption_CustomOnionMessageContentsZ_free(struct LDKCOption_CustomOnionMessageContentsZ _res); /** - * Creates a new CResult_NoneAPIErrorZ in the error state. + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(struct LDKCOption_CustomOnionMessageContentsZ o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. */ -bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o); +struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NoneAPIErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res); +bool CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneAPIErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. */ -struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig); +void CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type */ -void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res); +struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_TypeZ containing nothing */ -void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); +struct LDKCOption_TypeZ COption_TypeZ_none(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); +void COption_TypeZ_free(struct LDKCOption_TypeZ _res); /** - * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z + * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_some(struct LDKCVec_u8Z o); +struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); /** - * Constructs a new COption_CVec_u8ZZ containing nothing + * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_none(void); +struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_CVec_u8ZZ_free(struct LDKCOption_CVec_u8ZZ _res); +bool CResult_COption_TypeZDecodeErrorZ_is_ok(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_CVec_u8ZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. */ -struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_clone(const struct LDKCOption_CVec_u8ZZ *NONNULL_PTR orig); +void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); /** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. + * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_ok(struct LDKRecipientOnionFields o); +struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o); /** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. + * Constructs a new COption_NetAddressZ containing nothing */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_NetAddressZ COption_NetAddressZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state */ -bool CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR o); +void COption_NetAddressZ_free(struct LDKCOption_NetAddressZ _res); /** - * Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. + * Creates a new COption_NetAddressZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_RecipientOnionFieldsDecodeErrorZ_free(struct LDKCResult_RecipientOnionFieldsDecodeErrorZ _res); +struct LDKCOption_NetAddressZ COption_NetAddressZ_clone(const struct LDKCOption_NetAddressZ *NONNULL_PTR orig); /** - * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` + * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_clone(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR orig); +struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ C2Tuple_PublicKeyCOption_NetAddressZZ_clone(const struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR orig); /** - * Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim + * Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. */ -struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_some(enum LDKHTLCClaim o); +struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ C2Tuple_PublicKeyCOption_NetAddressZZ_new(struct LDKPublicKey a, struct LDKCOption_NetAddressZ b); /** - * Constructs a new COption_HTLCClaimZ containing nothing + * Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. */ -struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_none(void); +void C2Tuple_PublicKeyCOption_NetAddressZZ_free(struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res); /** - * Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_HTLCClaimZ_free(struct LDKCOption_HTLCClaimZ _res); +void CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res); /** - * Creates a new CResult_NoneNoneZ in the success state. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); /** - * Creates a new CResult_NoneNoneZ in the error state. + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); +bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneNoneZ. + * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. */ -void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); +void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); /** - * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. + * Creates a new CResult_NonePeerHandleErrorZ in the success state. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. + * Creates a new CResult_NonePeerHandleErrorZ in the error state. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); +bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. + * Frees any resources used by the CResult_NonePeerHandleErrorZ. */ -void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); +void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + * Creates a new CResult_boolPeerHandleErrorZ in the success state. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + * Creates a new CResult_boolPeerHandleErrorZ in the error state. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); +bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. + * Frees any resources used by the CResult_boolPeerHandleErrorZ. */ -void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); +void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + * Creates a new CResult_u32GraphSyncErrorZ in the success state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + * Creates a new CResult_u32GraphSyncErrorZ in the error state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); +bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + * Frees any resources used by the CResult_u32GraphSyncErrorZ. */ -void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); +void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * Constructs a new COption_KeyPairZ containing a crate::c_types::SecretKey + */ +struct LDKCOption_KeyPairZ COption_KeyPairZ_some(struct LDKSecretKey o); + +/** + * Constructs a new COption_KeyPairZ containing nothing + */ +struct LDKCOption_KeyPairZ COption_KeyPairZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state + */ +void COption_KeyPairZ_free(struct LDKCOption_KeyPairZ _res); + +/** + * Creates a new COption_KeyPairZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_KeyPairZ COption_KeyPairZ_clone(const struct LDKCOption_KeyPairZ *NONNULL_PTR orig); /** - * Constructs a new COption_u32Z containing a u32 + * Creates a new CResult_COption_KeyPairZNoneZ in the success state. */ -struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); +struct LDKCResult_COption_KeyPairZNoneZ CResult_COption_KeyPairZNoneZ_ok(struct LDKCOption_KeyPairZ o); /** - * Constructs a new COption_u32Z containing nothing + * Creates a new CResult_COption_KeyPairZNoneZ in the error state. */ -struct LDKCOption_u32Z COption_u32Z_none(void); +struct LDKCResult_COption_KeyPairZNoneZ CResult_COption_KeyPairZNoneZ_err(void); /** - * Frees any resources associated with the u32, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_u32Z_free(struct LDKCOption_u32Z _res); +bool CResult_COption_KeyPairZNoneZ_is_ok(const struct LDKCResult_COption_KeyPairZNoneZ *NONNULL_PTR o); /** - * Creates a new COption_u32Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_COption_KeyPairZNoneZ. */ -struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); +void CResult_COption_KeyPairZNoneZ_free(struct LDKCResult_COption_KeyPairZNoneZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + * Creates a new CResult_COption_KeyPairZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); +struct LDKCResult_COption_KeyPairZNoneZ CResult_COption_KeyPairZNoneZ_clone(const struct LDKCResult_COption_KeyPairZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + * Constructs a new COption_ScriptZ containing a crate::c_types::derived::CVec_u8Z */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_ScriptZ COption_ScriptZ_some(struct LDKCVec_u8Z o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_ScriptZ containing nothing */ -bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_ScriptZ COption_ScriptZ_none(void); /** - * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state */ -void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); +void COption_ScriptZ_free(struct LDKCOption_ScriptZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * Creates a new COption_ScriptZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_ScriptZ COption_ScriptZ_clone(const struct LDKCOption_ScriptZ *NONNULL_PTR orig); /** * Constructs a new COption_NoneZ containing a @@ -16451,17627 +22437,18048 @@ enum LDKCOption_NoneZ COption_NoneZ_none(void); void COption_NoneZ_free(enum LDKCOption_NoneZ _res); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); +void CVec_WitnessZ_free(struct LDKCVec_WitnessZ _res); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + * Constructs a new COption_i64Z containing a i64 */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_i64Z COption_i64Z_some(int64_t o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_i64Z containing nothing */ -bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_i64Z COption_i64Z_none(void); /** - * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. + * Frees any resources associated with the i64, if we are in the Some state */ -void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); +void COption_i64Z_free(struct LDKCOption_i64Z _res); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * Creates a new COption_i64Z which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_i64Z COption_i64Z_clone(const struct LDKCOption_i64Z *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + * Constructs a new COption_TxidZ containing a crate::c_types::ThirtyTwoBytes */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); +struct LDKCOption_TxidZ COption_TxidZ_some(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + * Constructs a new COption_TxidZ containing nothing */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_TxidZ COption_TxidZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state */ -bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); +void COption_TxidZ_free(struct LDKCOption_TxidZ _res); /** - * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + * Creates a new COption_TxidZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); +struct LDKCOption_TxidZ COption_TxidZ_clone(const struct LDKCOption_TxidZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_NetAddressDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NetAddressDecodeErrorZ in the error state. */ -void CVec_SignatureZ_free(struct LDKCVec_SignatureZ _res); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); +bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + * Frees any resources used by the CResult_NetAddressDecodeErrorZ. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); +void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); +void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); + +/** + * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. + */ +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); + +/** + * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. + */ +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. */ -void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); +void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + * Creates a new CResult_AcceptChannelV2DecodeErrorZ in the success state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); +struct LDKCResult_AcceptChannelV2DecodeErrorZ CResult_AcceptChannelV2DecodeErrorZ_ok(struct LDKAcceptChannelV2 o); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + * Creates a new CResult_AcceptChannelV2DecodeErrorZ in the error state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); +struct LDKCResult_AcceptChannelV2DecodeErrorZ CResult_AcceptChannelV2DecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o); +bool CResult_AcceptChannelV2DecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. + * Frees any resources used by the CResult_AcceptChannelV2DecodeErrorZ. */ -void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); +void CResult_AcceptChannelV2DecodeErrorZ_free(struct LDKCResult_AcceptChannelV2DecodeErrorZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + * Creates a new CResult_AcceptChannelV2DecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); +struct LDKCResult_AcceptChannelV2DecodeErrorZ CResult_AcceptChannelV2DecodeErrorZ_clone(const struct LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_TxAddInputDecodeErrorZ in the success state. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxAddInputDecodeErrorZ CResult_TxAddInputDecodeErrorZ_ok(struct LDKTxAddInput o); + +/** + * Creates a new CResult_TxAddInputDecodeErrorZ in the error state. + */ +struct LDKCResult_TxAddInputDecodeErrorZ CResult_TxAddInputDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxAddInputDecodeErrorZ_is_ok(const struct LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult_TxAddInputDecodeErrorZ. */ -void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); +void CResult_TxAddInputDecodeErrorZ_free(struct LDKCResult_TxAddInputDecodeErrorZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxAddInputDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxAddInputDecodeErrorZ CResult_TxAddInputDecodeErrorZ_clone(const struct LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + * Creates a new CResult_TxAddOutputDecodeErrorZ in the success state. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); +struct LDKCResult_TxAddOutputDecodeErrorZ CResult_TxAddOutputDecodeErrorZ_ok(struct LDKTxAddOutput o); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + * Creates a new CResult_TxAddOutputDecodeErrorZ in the error state. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); +struct LDKCResult_TxAddOutputDecodeErrorZ CResult_TxAddOutputDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); +bool CResult_TxAddOutputDecodeErrorZ_is_ok(const struct LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + * Frees any resources used by the CResult_TxAddOutputDecodeErrorZ. */ -void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); +void CResult_TxAddOutputDecodeErrorZ_free(struct LDKCResult_TxAddOutputDecodeErrorZ _res); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the success state. + * Creates a new CResult_TxAddOutputDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); +struct LDKCResult_TxAddOutputDecodeErrorZ CResult_TxAddOutputDecodeErrorZ_clone(const struct LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_SignatureZNoneZ in the error state. + * Creates a new CResult_TxRemoveInputDecodeErrorZ in the success state. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); +struct LDKCResult_TxRemoveInputDecodeErrorZ CResult_TxRemoveInputDecodeErrorZ_ok(struct LDKTxRemoveInput o); + +/** + * Creates a new CResult_TxRemoveInputDecodeErrorZ in the error state. + */ +struct LDKCResult_TxRemoveInputDecodeErrorZ CResult_TxRemoveInputDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_SignatureZNoneZ_is_ok(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR o); +bool CResult_TxRemoveInputDecodeErrorZ_is_ok(const struct LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_SignatureZNoneZ. + * Frees any resources used by the CResult_TxRemoveInputDecodeErrorZ. */ -void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); +void CResult_TxRemoveInputDecodeErrorZ_free(struct LDKCResult_TxRemoveInputDecodeErrorZ _res); /** - * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` + * Creates a new CResult_TxRemoveInputDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); +struct LDKCResult_TxRemoveInputDecodeErrorZ CResult_TxRemoveInputDecodeErrorZ_clone(const struct LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. + * Creates a new CResult_TxRemoveOutputDecodeErrorZ in the success state. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); +struct LDKCResult_TxRemoveOutputDecodeErrorZ CResult_TxRemoveOutputDecodeErrorZ_ok(struct LDKTxRemoveOutput o); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. + * Creates a new CResult_TxRemoveOutputDecodeErrorZ in the error state. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxRemoveOutputDecodeErrorZ CResult_TxRemoveOutputDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxRemoveOutputDecodeErrorZ_is_ok(const struct LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. + * Frees any resources used by the CResult_TxRemoveOutputDecodeErrorZ. */ -void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); +void CResult_TxRemoveOutputDecodeErrorZ_free(struct LDKCResult_TxRemoveOutputDecodeErrorZ _res); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxRemoveOutputDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxRemoveOutputDecodeErrorZ CResult_TxRemoveOutputDecodeErrorZ_clone(const struct LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. + * Creates a new CResult_TxCompleteDecodeErrorZ in the success state. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_ok(struct LDKShutdownScript o); +struct LDKCResult_TxCompleteDecodeErrorZ CResult_TxCompleteDecodeErrorZ_ok(struct LDKTxComplete o); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. + * Creates a new CResult_TxCompleteDecodeErrorZ in the error state. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e); +struct LDKCResult_TxCompleteDecodeErrorZ CResult_TxCompleteDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR o); +bool CResult_TxCompleteDecodeErrorZ_is_ok(const struct LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. + * Frees any resources used by the CResult_TxCompleteDecodeErrorZ. */ -void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res); +void CResult_TxCompleteDecodeErrorZ_free(struct LDKCResult_TxCompleteDecodeErrorZ _res); /** - * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` + * Creates a new CResult_TxCompleteDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); +struct LDKCResult_TxCompleteDecodeErrorZ CResult_TxCompleteDecodeErrorZ_clone(const struct LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. + * Creates a new CResult_TxSignaturesDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); +struct LDKCResult_TxSignaturesDecodeErrorZ CResult_TxSignaturesDecodeErrorZ_ok(struct LDKTxSignatures o); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. + * Creates a new CResult_TxSignaturesDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxSignaturesDecodeErrorZ CResult_TxSignaturesDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. + * Frees any resources used by the CResult_TxSignaturesDecodeErrorZ. */ -void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); +void CResult_TxSignaturesDecodeErrorZ_free(struct LDKCResult_TxSignaturesDecodeErrorZ _res); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxSignaturesDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxSignaturesDecodeErrorZ CResult_TxSignaturesDecodeErrorZ_clone(const struct LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore + * Creates a new CResult_TxInitRbfDecodeErrorZ in the success state. */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); +struct LDKCResult_TxInitRbfDecodeErrorZ CResult_TxInitRbfDecodeErrorZ_ok(struct LDKTxInitRbf o); /** - * Constructs a new COption_WriteableScoreZ containing nothing + * Creates a new CResult_TxInitRbfDecodeErrorZ in the error state. */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); +struct LDKCResult_TxInitRbfDecodeErrorZ CResult_TxInitRbfDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); +bool CResult_TxInitRbfDecodeErrorZ_is_ok(const struct LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneErrorZ in the success state. + * Frees any resources used by the CResult_TxInitRbfDecodeErrorZ. */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); +void CResult_TxInitRbfDecodeErrorZ_free(struct LDKCResult_TxInitRbfDecodeErrorZ _res); /** - * Creates a new CResult_NoneErrorZ in the error state. + * Creates a new CResult_TxInitRbfDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); +struct LDKCResult_TxInitRbfDecodeErrorZ CResult_TxInitRbfDecodeErrorZ_clone(const struct LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_TxAckRbfDecodeErrorZ in the success state. */ -bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); +struct LDKCResult_TxAckRbfDecodeErrorZ CResult_TxAckRbfDecodeErrorZ_ok(struct LDKTxAckRbf o); /** - * Frees any resources used by the CResult_NoneErrorZ. + * Creates a new CResult_TxAckRbfDecodeErrorZ in the error state. */ -void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); +struct LDKCResult_TxAckRbfDecodeErrorZ CResult_TxAckRbfDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_NoneErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); +bool CResult_TxAckRbfDecodeErrorZ_is_ok(const struct LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_TxAckRbfDecodeErrorZ. */ -void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); +void CResult_TxAckRbfDecodeErrorZ_free(struct LDKCResult_TxAckRbfDecodeErrorZ _res); /** - * Creates a new CResult_RouteLightningErrorZ in the success state. + * Creates a new CResult_TxAckRbfDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); +struct LDKCResult_TxAckRbfDecodeErrorZ CResult_TxAckRbfDecodeErrorZ_clone(const struct LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteLightningErrorZ in the error state. + * Creates a new CResult_TxAbortDecodeErrorZ in the success state. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_TxAbortDecodeErrorZ CResult_TxAbortDecodeErrorZ_ok(struct LDKTxAbort o); + +/** + * Creates a new CResult_TxAbortDecodeErrorZ in the error state. + */ +struct LDKCResult_TxAbortDecodeErrorZ CResult_TxAbortDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteLightningErrorZ_is_ok(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR o); +bool CResult_TxAbortDecodeErrorZ_is_ok(const struct LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteLightningErrorZ. + * Frees any resources used by the CResult_TxAbortDecodeErrorZ. */ -void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); +void CResult_TxAbortDecodeErrorZ_free(struct LDKCResult_TxAbortDecodeErrorZ _res); /** - * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` + * Creates a new CResult_TxAbortDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxAbortDecodeErrorZ CResult_TxAbortDecodeErrorZ_clone(const struct LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_ok(struct LDKInFlightHtlcs o); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); /** - * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InFlightHtlcsDecodeErrorZ_is_ok(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR o); +bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. + * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. */ -void CResult_InFlightHtlcsDecodeErrorZ_free(struct LDKCResult_InFlightHtlcsDecodeErrorZ _res); +void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); /** - * Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ CResult_InFlightHtlcsDecodeErrorZ_clone(const struct LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHopDecodeErrorZ in the success state. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_ok(struct LDKRouteHop o); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); /** - * Creates a new CResult_RouteHopDecodeErrorZ in the error state. + * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHopDecodeErrorZ. + * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. */ -void CResult_RouteHopDecodeErrorZ_free(struct LDKCResult_RouteHopDecodeErrorZ _res); +void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); /** - * Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_clone(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. */ -void CVec_BlindedHopZ_free(struct LDKCVec_BlindedHopZ _res); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); /** - * Creates a new CResult_BlindedTailDecodeErrorZ in the success state. + * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_ok(struct LDKBlindedTail o); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_BlindedTailDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. */ -bool CResult_BlindedTailDecodeErrorZ_is_ok(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR o); +void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); /** - * Frees any resources used by the CResult_BlindedTailDecodeErrorZ. + * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_BlindedTailDecodeErrorZ_free(struct LDKCResult_BlindedTailDecodeErrorZ _res); +struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_clone(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(struct LDKClosingSignedFeeRange o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. */ -void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state + */ +bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. + */ +void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res); + +/** + * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_PathZ_free(struct LDKCVec_PathZ _res); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteDecodeErrorZ in the success state. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute o); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); /** - * Creates a new CResult_RouteDecodeErrorZ in the error state. + * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteDecodeErrorZ_is_ok(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR o); +bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteDecodeErrorZ. + * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. */ -void CResult_RouteDecodeErrorZ_free(struct LDKCResult_RouteDecodeErrorZ _res); +void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); /** - * Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_clone(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteParametersDecodeErrorZ in the success state. + * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_ok(struct LDKRouteParameters o); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); /** - * Creates a new CResult_RouteParametersDecodeErrorZ in the error state. + * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteParametersDecodeErrorZ_is_ok(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR o); +bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteParametersDecodeErrorZ. + * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. */ -void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersDecodeErrorZ _res); +void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); /** - * Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_u64Z_free(struct LDKCVec_u64Z _res); +struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_ok(struct LDKPaymentParameters o); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. + * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentParametersDecodeErrorZ_is_ok(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. - */ -void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParametersDecodeErrorZ _res); +bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. */ -struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_clone(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR orig); +void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_clone(const struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR orig); +struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. + * Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. */ -struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_new(struct LDKBlindedPayInfo a, struct LDKBlindedPath b); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_ok(struct LDKChannelReady o); /** - * Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. + * Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. */ -void C2Tuple_BlindedPayInfoBlindedPathZ_free(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ _res); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res); +bool CResult_ChannelReadyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. */ -void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); +void CResult_ChannelReadyDecodeErrorZ_free(struct LDKCResult_ChannelReadyDecodeErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); +struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_clone(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the success state. + * Creates a new CResult_InitDecodeErrorZ in the success state. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the error state. + * Creates a new CResult_InitDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteHintDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR o); +bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHintDecodeErrorZ. + * Frees any resources used by the CResult_InitDecodeErrorZ. */ -void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res); +void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); /** - * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. + * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. + * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RouteHintHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR o); +bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. + * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. */ -void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res); +void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); +struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_OpenChannelV2DecodeErrorZ in the success state. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_clone(const struct LDKC2Tuple_usizeTransactionZ *NONNULL_PTR orig); +struct LDKCResult_OpenChannelV2DecodeErrorZ CResult_OpenChannelV2DecodeErrorZ_ok(struct LDKOpenChannelV2 o); /** - * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + * Creates a new CResult_OpenChannelV2DecodeErrorZ in the error state. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); +struct LDKCResult_OpenChannelV2DecodeErrorZ CResult_OpenChannelV2DecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C2Tuple_usizeTransactionZ. + * Checks if the given object is currently in the success state */ -void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); +bool CResult_OpenChannelV2DecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_OpenChannelV2DecodeErrorZ. */ -void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); +void CResult_OpenChannelV2DecodeErrorZ_free(struct LDKCResult_OpenChannelV2DecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_OpenChannelV2DecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_TxidBlockHashZ C2Tuple_TxidBlockHashZ_clone(const struct LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR orig); +struct LDKCResult_OpenChannelV2DecodeErrorZ CResult_OpenChannelV2DecodeErrorZ_clone(const struct LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_TxidBlockHashZ from the contained elements. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. */ -struct LDKC2Tuple_TxidBlockHashZ C2Tuple_TxidBlockHashZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); /** - * Frees any resources used by the C2Tuple_TxidBlockHashZ. + * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. */ -void C2Tuple_TxidBlockHashZ_free(struct LDKC2Tuple_TxidBlockHashZ _res); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_C2Tuple_TxidBlockHashZZ_free(struct LDKCVec_C2Tuple_TxidBlockHashZZ _res); +bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. */ -void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); +void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(const struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR orig); +struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. + * Creates a new CResult_ShutdownDecodeErrorZ in the success state. */ -struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorEventZ b, struct LDKPublicKey c); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); /** - * Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. + * Creates a new CResult_ShutdownDecodeErrorZ in the error state. */ -void C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res); +bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. + * Frees any resources used by the CResult_ShutdownDecodeErrorZ. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); +void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); /** - * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. + * Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. */ -bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); /** - * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. */ -void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_clone(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR orig); +bool CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. */ -struct LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const struct LDKC2Tuple_u64u64Z *NONNULL_PTR orig); +void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); /** - * Creates a new C2Tuple_u64u64Z from the contained elements. + * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_u64u64Z. + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. */ -void C2Tuple_u64u64Z_free(struct LDKC2Tuple_u64u64Z _res); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); /** - * Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. */ -struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_some(struct LDKC2Tuple_u64u64Z o); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_C2Tuple_u64u64ZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_none(void); +bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state + * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. */ -void COption_C2Tuple_u64u64ZZ_free(struct LDKCOption_C2Tuple_u64u64ZZ _res); +void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); /** - * Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` + * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_C2Tuple_u64u64ZZ COption_C2Tuple_u64u64ZZ_clone(const struct LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. */ -struct LDKC2Tuple_Z C2Tuple_Z_clone(const struct LDKC2Tuple_Z *NONNULL_PTR orig); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); /** - * Creates a new C2Tuple_Z from the contained elements. + * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. */ -struct LDKC2Tuple_Z C2Tuple_Z_new(struct LDKEightU16s a, struct LDKEightU16s b); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C2Tuple_Z. + * Checks if the given object is currently in the success state */ -void C2Tuple_Z_free(struct LDKC2Tuple_Z _res); +bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. */ -struct LDKC2Tuple__u168_u168Z C2Tuple__u168_u168Z_clone(const struct LDKC2Tuple__u168_u168Z *NONNULL_PTR orig); +void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); /** - * Creates a new C2Tuple__u168_u168Z from the contained elements. + * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple__u168_u168Z C2Tuple__u168_u168Z_new(struct LDKEightU16s a, struct LDKEightU16s b); +struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple__u168_u168Z. + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. */ -void C2Tuple__u168_u168Z_free(struct LDKC2Tuple__u168_u168Z _res); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); /** - * Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. */ -struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_some(struct LDKC2Tuple__u168_u168Z o); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_none(void); +bool CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state + * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. */ -void COption_C2Tuple_EightU16sEightU16sZZ_free(struct LDKCOption_C2Tuple_EightU16sEightU16sZZ _res); +void CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); /** - * Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` + * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_C2Tuple_EightU16sEightU16sZZ COption_C2Tuple_EightU16sEightU16sZZ_clone(const struct LDKCOption_C2Tuple_EightU16sEightU16sZZ *NONNULL_PTR orig); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. */ -void CVec_NodeIdZ_free(struct LDKCVec_NodeIdZ _res); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); /** - * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. */ -bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o); +void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); /** - * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. + * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_OnionMessageDecodeErrorZ in the success state. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(struct LDKInitFeatures o); +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_ok(struct LDKOnionMessage o); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_OnionMessageDecodeErrorZ in the error state. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InitFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_OnionMessageDecodeErrorZ_is_ok(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_OnionMessageDecodeErrorZ. */ -void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); +void CResult_OnionMessageDecodeErrorZ_free(struct LDKCResult_OnionMessageDecodeErrorZ _res); /** - * Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_clone(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_clone(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_PingDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_PingDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_PingDecodeErrorZ. */ -void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_PongDecodeErrorZ in the success state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_PongDecodeErrorZ in the error state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NodeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_PongDecodeErrorZ. */ -void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); +void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_clone(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. */ -void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); +void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_clone(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_ok(struct LDKBlindedHopFeatures o); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); /** - * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. */ -void CResult_BlindedHopFeaturesDecodeErrorZ_free(struct LDKCResult_BlindedHopFeaturesDecodeErrorZ _res); +void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ CResult_BlindedHopFeaturesDecodeErrorZ_clone(const struct LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); /** - * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o); +bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. + * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. */ -void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res); +void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); /** - * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_ok(struct LDKPaymentPurpose o); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); /** - * Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentPurposeDecodeErrorZ_is_ok(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. + * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. */ -void CResult_PaymentPurposeDecodeErrorZ_free(struct LDKCResult_PaymentPurposeDecodeErrorZ _res); +void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); /** - * Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_clone(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate + * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); /** - * Constructs a new COption_NetworkUpdateZ containing nothing + * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); +bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. + */ +void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure + * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_some(struct LDKPathFailure o); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); /** - * Constructs a new COption_PathFailureZ containing nothing + * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_none(void); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_PathFailureZ_free(struct LDKCOption_PathFailureZ _res); +bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_PathFailureZ which has the same data as `orig` + * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. + */ +void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_clone(const struct LDKCOption_PathFailureZ *NONNULL_PTR orig); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_ok(struct LDKCOption_PathFailureZ o); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); /** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_PathFailureZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR o); +bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. + * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. */ -void CResult_COption_PathFailureZDecodeErrorZ_free(struct LDKCResult_COption_PathFailureZDecodeErrorZ _res); +void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); /** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_clone(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); /** - * Constructs a new COption_ClosureReasonZ containing nothing + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); +bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_ClosureReasonZ which has the same data as `orig` + * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. + */ +void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); + +/** + * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); +bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. + * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. */ -void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); +void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); /** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_some(struct LDKHTLCDestination o); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); /** - * Constructs a new COption_HTLCDestinationZ containing nothing + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_none(void); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state + * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. */ -void COption_HTLCDestinationZ_free(struct LDKCOption_HTLCDestinationZ _res); +void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); /** - * Creates a new COption_HTLCDestinationZ which has the same data as `orig` + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_clone(const struct LDKCOption_HTLCDestinationZ *NONNULL_PTR orig); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_ok(struct LDKCOption_HTLCDestinationZ o); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); /** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR o); +bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. + * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. */ -void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res); +void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); /** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_ok(enum LDKPaymentFailureReason o); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentFailureReasonDecodeErrorZ_is_ok(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR o); +bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. + * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. */ -void CResult_PaymentFailureReasonDecodeErrorZ_free(struct LDKCResult_PaymentFailureReasonDecodeErrorZ _res); +void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_clone(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_u128Z containing a crate::c_types::U128 + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. */ -struct LDKCOption_u128Z COption_u128Z_some(struct LDKU128 o); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); /** - * Constructs a new COption_u128Z containing nothing + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. */ -struct LDKCOption_u128Z COption_u128Z_none(void); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::c_types::U128, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_u128Z_free(struct LDKCOption_u128Z _res); +bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_u128Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. */ -struct LDKCOption_u128Z COption_u128Z_clone(const struct LDKCOption_u128Z *NONNULL_PTR orig); +void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); /** - * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_PaymentFailureReasonZ containing nothing + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); /** - * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. */ -void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(struct LDKBolt11Invoice o); /** - * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); +bool CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR o); /** - * Constructs a new COption_EventZ containing a crate::lightning::events::Event + * Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. */ -struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); +void CResult_Bolt11InvoiceSignOrCreationErrorZ_free(struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res); /** - * Constructs a new COption_EventZ containing nothing + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_EventZ COption_EventZ_none(void); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); /** - * Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_EventZ_free(struct LDKCOption_EventZ _res); +void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); /** - * Creates a new COption_EventZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_OffersMessageDecodeErrorZ in the success state. */ -struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_ok(struct LDKOffersMessage o); /** - * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. + * Creates a new CResult_OffersMessageDecodeErrorZ in the error state. */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_OffersMessageDecodeErrorZ_is_ok(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_OffersMessageDecodeErrorZ. */ -bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); +void CResult_OffersMessageDecodeErrorZ_free(struct LDKCResult_OffersMessageDecodeErrorZ _res); /** - * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. + * Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_clone(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_some(enum LDKHTLCClaim o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_HTLCClaimZ containing nothing */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_none(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state */ -void CVec_ChainHashZ_free(struct LDKCVec_ChainHashZ _res); +void COption_HTLCClaimZ_free(struct LDKCOption_HTLCClaimZ _res); /** - * Creates a new CResult_PublicKeyErrorZ in the success state. + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); /** - * Creates a new CResult_PublicKeyErrorZ in the error state. + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); +bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeyErrorZ. + * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. */ -void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); +void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); /** - * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeIdDecodeErrorZ in the success state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_ok(struct LDKNodeId o); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); /** - * Creates a new CResult_NodeIdDecodeErrorZ in the error state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NodeIdDecodeErrorZ_is_ok(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NodeIdDecodeErrorZ. + * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. */ -void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); +void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); /** - * Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_ok(struct LDKCOption_NetworkUpdateZ o); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. + * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. */ -void CResult_COption_NetworkUpdateZDecodeErrorZ_free(struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res); +void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); /** - * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_clone(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_UtxoLookupZ containing a crate::lightning::routing::utxo::UtxoLookup + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. */ -struct LDKCOption_UtxoLookupZ COption_UtxoLookupZ_some(struct LDKUtxoLookup o); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); /** - * Constructs a new COption_UtxoLookupZ containing nothing + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. */ -struct LDKCOption_UtxoLookupZ COption_UtxoLookupZ_none(void); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_UtxoLookupZ_free(struct LDKCOption_UtxoLookupZ _res); +bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_boolLightningErrorZ in the success state. + * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); +void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); /** - * Creates a new CResult_boolLightningErrorZ in the error state. + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. */ -bool CResult_boolLightningErrorZ_is_ok(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR o); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); /** - * Frees any resources used by the CResult_boolLightningErrorZ. + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. */ -void CResult_boolLightningErrorZ_free(struct LDKCResult_boolLightningErrorZ _res); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_boolLightningErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_clone(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR orig); +bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR orig); +void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); /** - * Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(struct LDKChannelAnnouncement a, struct LDKChannelUpdate b, struct LDKChannelUpdate c); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. */ -void C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); /** - * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. */ -struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(struct LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none(void); +bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state + * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. */ -void COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res); +void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); /** - * Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig` + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const struct LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR orig); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneLightningErrorZ in the success state. + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); /** - * Creates a new CResult_NoneLightningErrorZ in the error state. + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneLightningErrorZ_is_ok(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR o); +bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneLightningErrorZ. + * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. */ -void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res); +void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); /** - * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_ok(struct LDKChannelUpdateInfo o); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. + * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. */ -void CResult_ChannelUpdateInfoDecodeErrorZ_free(struct LDKCResult_ChannelUpdateInfoDecodeErrorZ _res); +void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); /** - * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. + * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(struct LDKChannelInfo o); +struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. + * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. - */ -void CResult_ChannelInfoDecodeErrorZ_free(struct LDKCResult_ChannelInfoDecodeErrorZ _res); +bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. */ -struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR orig); +void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(struct LDKRoutingFees o); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_RoutingFeesDecodeErrorZ_is_ok(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR o); +bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. + * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. */ -void CResult_RoutingFeesDecodeErrorZ_free(struct LDKCResult_RoutingFeesDecodeErrorZ _res); +void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); /** - * Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_clone(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_NetAddressZ_free(struct LDKCVec_NetAddressZ _res); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_ok(struct LDKNodeAnnouncementInfo o); +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. - */ -void CResult_NodeAnnouncementInfoDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res); +bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR orig); +void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); /** - * Creates a new CResult_NodeAliasDecodeErrorZ in the success state. + * Creates a new CResult_CVec_SignatureZNoneZ in the success state. */ -struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_ok(struct LDKNodeAlias o); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LDKCVec_SignatureZ o); /** - * Creates a new CResult_NodeAliasDecodeErrorZ in the error state. + * Creates a new CResult_CVec_SignatureZNoneZ in the error state. */ -struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NodeAliasDecodeErrorZ_is_ok(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR o); +bool CResult_CVec_SignatureZNoneZ_is_ok(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NodeAliasDecodeErrorZ. + * Frees any resources used by the CResult_CVec_SignatureZNoneZ. */ -void CResult_NodeAliasDecodeErrorZ_free(struct LDKCResult_NodeAliasDecodeErrorZ _res); +void CResult_CVec_SignatureZNoneZ_free(struct LDKCResult_CVec_SignatureZNoneZ _res); /** - * Creates a new CResult_NodeAliasDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_clone(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_clone(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LDKNodeInfo o); +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); /** - * Creates a new CResult_NodeInfoDecodeErrorZ in the error state. + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NodeInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. + * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. */ -void CResult_NodeInfoDecodeErrorZ_free(struct LDKCResult_NodeInfoDecodeErrorZ _res); +void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); /** - * Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_clone(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(struct LDKNetworkGraph o); +struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_ok(struct LDKShutdownScript o); /** - * Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. */ -struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e); /** * Checks if the given object is currently in the success state */ -bool CResult_NetworkGraphDecodeErrorZ_is_ok(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. - */ -void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res); - -/** - * Constructs a new COption_CVec_NetAddressZZ containing a crate::c_types::derived::CVec_NetAddressZ - */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_some(struct LDKCVec_NetAddressZ o); - -/** - * Constructs a new COption_CVec_NetAddressZZ containing nothing - */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_none(void); +bool CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::derived::CVec_NetAddressZ, if we are in the Some state + * Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. */ -void COption_CVec_NetAddressZZ_free(struct LDKCOption_CVec_NetAddressZZ _res); +void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res); /** - * Creates a new COption_CVec_NetAddressZZ which has the same data as `orig` + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_CVec_NetAddressZZ COption_CVec_NetAddressZZ_clone(const struct LDKCOption_CVec_NetAddressZZ *NONNULL_PTR orig); +struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKDelayedPaymentOutputDescriptor o); +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_ok(struct LDKPaymentPurpose o); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. + * Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentPurposeDecodeErrorZ_is_ok(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. + * Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. */ -void CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res); +void CResult_PaymentPurposeDecodeErrorZ_free(struct LDKCResult_PaymentPurposeDecodeErrorZ _res); /** - * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. - */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(struct LDKStaticPaymentOutputDescriptor o); +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_clone(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. + * Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_PathFailureZ COption_PathFailureZ_some(struct LDKPathFailure o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_PathFailureZ containing nothing */ -bool CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_PathFailureZ COption_PathFailureZ_none(void); /** - * Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. + * Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state */ -void CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res); +void COption_PathFailureZ_free(struct LDKCOption_PathFailureZ _res); /** - * Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` + * Creates a new COption_PathFailureZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_PathFailureZ COption_PathFailureZ_clone(const struct LDKCOption_PathFailureZ *NONNULL_PTR orig); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. + * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_ok(struct LDKSpendableOutputDescriptor o); +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_ok(struct LDKCOption_PathFailureZ o); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. + * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR o); +bool CResult_COption_PathFailureZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. + * Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. */ -void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res); +void CResult_COption_PathFailureZDecodeErrorZ_free(struct LDKCResult_COption_PathFailureZDecodeErrorZ _res); /** - * Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_clone(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason */ -void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_ClosureReasonZ containing nothing */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); /** - * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + * Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); +void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); /** - * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + * Creates a new COption_ClosureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); +bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. */ -void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); +void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_SignatureNoneZ in the success state. - */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignatureNoneZ in the error state. + * Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_some(struct LDKHTLCDestination o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_HTLCDestinationZ containing nothing */ -bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_none(void); /** - * Frees any resources used by the CResult_SignatureNoneZ. + * Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state */ -void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); +void COption_HTLCDestinationZ_free(struct LDKCOption_HTLCDestinationZ _res); /** - * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * Creates a new COption_HTLCDestinationZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_clone(const struct LDKCOption_HTLCDestinationZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeyNoneZ in the success state. + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_ok(struct LDKCOption_HTLCDestinationZ o); /** - * Creates a new CResult_PublicKeyNoneZ in the error state. + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); +bool CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeyNoneZ. + * Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. */ -void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); +void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res); /** - * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. */ -struct LDKCOption_ScalarZ COption_ScalarZ_some(struct LDKBigEndianScalar o); +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_ok(enum LDKPaymentFailureReason o); /** - * Constructs a new COption_ScalarZ containing nothing + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. */ -struct LDKCOption_ScalarZ COption_ScalarZ_none(void); +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_ScalarZ_free(struct LDKCOption_ScalarZ _res); +bool CResult_PaymentFailureReasonDecodeErrorZ_is_ok(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_ScalarZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. */ -struct LDKCOption_ScalarZ COption_ScalarZ_clone(const struct LDKCOption_ScalarZ *NONNULL_PTR orig); +void CResult_PaymentFailureReasonDecodeErrorZ_free(struct LDKCResult_PaymentFailureReasonDecodeErrorZ _res); /** - * Creates a new CResult_SharedSecretNoneZ in the success state. + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_clone(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SharedSecretNoneZ in the error state. + * Constructs a new COption_u128Z containing a crate::c_types::U128 */ -struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_err(void); +struct LDKCOption_u128Z COption_u128Z_some(struct LDKU128 o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_u128Z containing nothing */ -bool CResult_SharedSecretNoneZ_is_ok(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR o); +struct LDKCOption_u128Z COption_u128Z_none(void); /** - * Frees any resources used by the CResult_SharedSecretNoneZ. + * Frees any resources associated with the crate::c_types::U128, if we are in the Some state */ -void CResult_SharedSecretNoneZ_free(struct LDKCResult_SharedSecretNoneZ _res); +void COption_u128Z_free(struct LDKCOption_u128Z _res); /** - * Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` + * Creates a new COption_u128Z which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SharedSecretNoneZ CResult_SharedSecretNoneZ_clone(const struct LDKCResult_SharedSecretNoneZ *NONNULL_PTR orig); +struct LDKCOption_u128Z COption_u128Z_clone(const struct LDKCOption_u128Z *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_PaymentIdZ containing a crate::c_types::ThirtyTwoBytes */ -void CVec_U5Z_free(struct LDKCVec_U5Z _res); +struct LDKCOption_PaymentIdZ COption_PaymentIdZ_some(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_RecoverableSignatureNoneZ in the success state. + * Constructs a new COption_PaymentIdZ containing nothing */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_ok(struct LDKRecoverableSignature o); +struct LDKCOption_PaymentIdZ COption_PaymentIdZ_none(void); /** - * Creates a new CResult_RecoverableSignatureNoneZ in the error state. + * Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void); +void COption_PaymentIdZ_free(struct LDKCOption_PaymentIdZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new COption_PaymentIdZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o); +struct LDKCOption_PaymentIdZ COption_PaymentIdZ_clone(const struct LDKCOption_PaymentIdZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_RecoverableSignatureNoneZ. + * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason */ -void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatureNoneZ _res); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); /** - * Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new COption_PaymentFailureReasonZ containing nothing */ -struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. + * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(struct LDKWriteableEcdsaChannelSigner o); +void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. + * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_EventZ containing a crate::lightning::events::Event */ -bool CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); /** - * Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. + * Constructs a new COption_EventZ containing nothing */ -void CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res); +struct LDKCOption_EventZ COption_EventZ_none(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state */ -void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res); +void COption_EventZ_free(struct LDKCOption_EventZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. + * Creates a new COption_EventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o); +struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. + * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o); +bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. + * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. */ -void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res); +void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); /** - * Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` + * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ok(struct LDKInMemorySigner o); +void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); + +/** + * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. + */ +struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o); +bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. + * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. */ -void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDecodeErrorZ _res); +void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); /** - * Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. */ -struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SiPrefixBolt11ParseErrorZ CResult_SiPrefixBolt11ParseErrorZ_ok(enum LDKSiPrefix o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_SiPrefixBolt11ParseErrorZ in the error state. */ -void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res); +struct LDKCResult_SiPrefixBolt11ParseErrorZ CResult_SiPrefixBolt11ParseErrorZ_err(struct LDKBolt11ParseError e); /** - * Creates a new CResult_TransactionNoneZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); +bool CResult_SiPrefixBolt11ParseErrorZ_is_ok(const struct LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_TransactionNoneZ in the error state. + * Frees any resources used by the CResult_SiPrefixBolt11ParseErrorZ. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +void CResult_SiPrefixBolt11ParseErrorZ_free(struct LDKCResult_SiPrefixBolt11ParseErrorZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_SiPrefixBolt11ParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); +struct LDKCResult_SiPrefixBolt11ParseErrorZ CResult_SiPrefixBolt11ParseErrorZ_clone(const struct LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_TransactionNoneZ. + * Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the success state. */ -void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); +struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(struct LDKBolt11Invoice o); /** - * Creates a new CResult_TransactionNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the error state. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); /** - * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. + * Checks if the given object is currently in the success state */ -struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); +bool CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. + * Frees any resources used by the CResult_Bolt11InvoiceParseOrSemanticErrorZ. */ -void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); +void CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); +struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. + * Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); +struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(struct LDKSignedRawBolt11Invoice o); /** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. + * Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); +struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(struct LDKBolt11ParseError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); +bool CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(const struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. + * Frees any resources used by the CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ. */ -void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); +void CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ _res); /** - * Constructs a new COption_u16Z containing a u16 + * Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); +struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(const struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_u16Z containing nothing + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_u16Z COption_u16Z_none(void); +struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR orig); /** - * Frees any resources associated with the u16, if we are in the Some state + * Creates a new C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ from the contained elements. */ -void COption_u16Z_free(struct LDKCOption_u16Z _res); +struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(struct LDKRawBolt11Invoice a, struct LDKThirtyTwoBytes b, struct LDKBolt11InvoiceSignature c); /** - * Creates a new COption_u16Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ. */ -struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); +void C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ _res); /** - * Creates a new CResult__u832APIErrorZ in the success state. + * Creates a new CResult_PayeePubKeyErrorZ in the success state. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); /** - * Creates a new CResult__u832APIErrorZ in the error state. + * Creates a new CResult_PayeePubKeyErrorZ in the error state. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); /** * Checks if the given object is currently in the success state */ -bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o); +bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult__u832APIErrorZ. + * Frees any resources used by the CResult_PayeePubKeyErrorZ. */ -void CResult__u832APIErrorZ_free(struct LDKCResult__u832APIErrorZ _res); +void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); /** - * Creates a new CResult__u832APIErrorZ which has the same data as `orig` + * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_clone(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR orig); +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_RecentPaymentDetailsZ_free(struct LDKCVec_RecentPaymentDetailsZ _res); +void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); /** - * Creates a new CResult_NonePaymentSendFailureZ in the success state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); /** - * Creates a new CResult_NonePaymentSendFailureZ in the error state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o); +bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NonePaymentSendFailureZ. + * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. */ -void CResult_NonePaymentSendFailureZ_free(struct LDKCResult_NonePaymentSendFailureZ _res); +void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); /** - * Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` + * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_clone(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneRetryableSendFailureZ in the success state. + * Creates a new CResult_NoneBolt11SemanticErrorZ in the success state. */ -struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_ok(void); +struct LDKCResult_NoneBolt11SemanticErrorZ CResult_NoneBolt11SemanticErrorZ_ok(void); /** - * Creates a new CResult_NoneRetryableSendFailureZ in the error state. + * Creates a new CResult_NoneBolt11SemanticErrorZ in the error state. */ -struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_err(enum LDKRetryableSendFailure e); +struct LDKCResult_NoneBolt11SemanticErrorZ CResult_NoneBolt11SemanticErrorZ_err(enum LDKBolt11SemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneRetryableSendFailureZ_is_ok(const struct LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR o); +bool CResult_NoneBolt11SemanticErrorZ_is_ok(const struct LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneRetryableSendFailureZ. + * Frees any resources used by the CResult_NoneBolt11SemanticErrorZ. */ -void CResult_NoneRetryableSendFailureZ_free(struct LDKCResult_NoneRetryableSendFailureZ _res); +void CResult_NoneBolt11SemanticErrorZ_free(struct LDKCResult_NoneBolt11SemanticErrorZ _res); /** - * Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` + * Creates a new CResult_NoneBolt11SemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneRetryableSendFailureZ CResult_NoneRetryableSendFailureZ_clone(const struct LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_NoneBolt11SemanticErrorZ CResult_NoneBolt11SemanticErrorZ_clone(const struct LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. + * Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the success state. */ -struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(struct LDKBolt11Invoice o); /** - * Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. + * Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the error state. */ -struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(enum LDKBolt11SemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentHashPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR o); +bool CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. + * Frees any resources used by the CResult_Bolt11InvoiceBolt11SemanticErrorZ. */ -void CResult_PaymentHashPaymentSendFailureZ_free(struct LDKCResult_PaymentHashPaymentSendFailureZ _res); +void CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ _res); /** - * Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` + * Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentHashPaymentSendFailureZ CResult_PaymentHashPaymentSendFailureZ_clone(const struct LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(const struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_ok(struct LDKThirtyTwoBytes o); +void CVec_AddressZ_free(struct LDKCVec_AddressZ _res); /** - * Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. + * Creates a new CResult_DescriptionCreationErrorZ in the success state. */ -struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_err(enum LDKRetryableSendFailure e); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); /** - * Checks if the given object is currently in the success state + * Creates a new CResult_DescriptionCreationErrorZ in the error state. */ -bool CResult_PaymentHashRetryableSendFailureZ_is_ok(const struct LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR o); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); /** - * Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. + * Checks if the given object is currently in the success state */ -void CResult_PaymentHashRetryableSendFailureZ_free(struct LDKCResult_PaymentHashRetryableSendFailureZ _res); +bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_DescriptionCreationErrorZ. */ -struct LDKCResult_PaymentHashRetryableSendFailureZ CResult_PaymentHashRetryableSendFailureZ_clone(const struct LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR orig); +void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_clone(const struct LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. - */ -struct LDKC2Tuple_PaymentHashPaymentIdZ C2Tuple_PaymentHashPaymentIdZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. + * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. */ -void C2Tuple_PaymentHashPaymentIdZ_free(struct LDKC2Tuple_PaymentHashPaymentIdZ _res); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. + * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(struct LDKC2Tuple_PaymentHashPaymentIdZ o); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. */ -bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o); +void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. + * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res); +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_OutPointDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR orig); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_OutPointDecodeErrorZ in the error state. */ -void CVec_ThirtyTwoBytesZ_free(struct LDKCVec_ThirtyTwoBytesZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if the given object is currently in the success state */ -struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_clone(const struct LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR orig); +bool CResult_OutPointDecodeErrorZ_is_ok(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. + * Frees any resources used by the CResult_OutPointDecodeErrorZ. */ -struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_new(struct LDKThirtyTwoBytes a, struct LDKThirtyTwoBytes b); +void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); /** - * Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. + * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); +struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. + * Creates a new CResult_BigSizeDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); +struct LDKCResult_BigSizeDecodeErrorZ CResult_BigSizeDecodeErrorZ_ok(struct LDKBigSize o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. + * Creates a new CResult_BigSizeDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void); +struct LDKCResult_BigSizeDecodeErrorZ CResult_BigSizeDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR o); +bool CResult_BigSizeDecodeErrorZ_is_ok(const struct LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. + * Frees any resources used by the CResult_BigSizeDecodeErrorZ. */ -void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res); +void CResult_BigSizeDecodeErrorZ_free(struct LDKCResult_BigSizeDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` + * Creates a new CResult_BigSizeDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR orig); +struct LDKCResult_BigSizeDecodeErrorZ CResult_BigSizeDecodeErrorZ_clone(const struct LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. + * Creates a new CResult_HostnameDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); +struct LDKCResult_HostnameDecodeErrorZ CResult_HostnameDecodeErrorZ_ok(struct LDKHostname o); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. + * Creates a new CResult_HostnameDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_HostnameDecodeErrorZ CResult_HostnameDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR o); +bool CResult_HostnameDecodeErrorZ_is_ok(const struct LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. + * Frees any resources used by the CResult_HostnameDecodeErrorZ. */ -void CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res); +void CResult_HostnameDecodeErrorZ_free(struct LDKCResult_HostnameDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig` + * Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_HostnameDecodeErrorZ CResult_HostnameDecodeErrorZ_clone(const struct LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentSecretNoneZ in the success state. + * Creates a new CResult_TransactionU16LenLimitedNoneZ in the success state. */ -struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_TransactionU16LenLimitedNoneZ CResult_TransactionU16LenLimitedNoneZ_ok(struct LDKTransactionU16LenLimited o); /** - * Creates a new CResult_PaymentSecretNoneZ in the error state. + * Creates a new CResult_TransactionU16LenLimitedNoneZ in the error state. */ -struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void); +struct LDKCResult_TransactionU16LenLimitedNoneZ CResult_TransactionU16LenLimitedNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o); +bool CResult_TransactionU16LenLimitedNoneZ_is_ok(const struct LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentSecretNoneZ. + * Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. */ -void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res); +void CResult_TransactionU16LenLimitedNoneZ_free(struct LDKCResult_TransactionU16LenLimitedNoneZ _res); /** - * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` + * Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_clone(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR orig); +struct LDKCResult_TransactionU16LenLimitedNoneZ CResult_TransactionU16LenLimitedNoneZ_clone(const struct LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentSecretAPIErrorZ in the success state. + * Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ CResult_TransactionU16LenLimitedDecodeErrorZ_ok(struct LDKTransactionU16LenLimited o); /** - * Creates a new CResult_PaymentSecretAPIErrorZ in the error state. + * Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ CResult_TransactionU16LenLimitedDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentSecretAPIErrorZ_is_ok(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR o); +bool CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(const struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentSecretAPIErrorZ. + * Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. */ -void CResult_PaymentSecretAPIErrorZ_free(struct LDKCResult_PaymentSecretAPIErrorZ _res); +void CResult_TransactionU16LenLimitedDecodeErrorZ_free(struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ _res); /** - * Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig` + * Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_clone(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ CResult_TransactionU16LenLimitedDecodeErrorZ_clone(const struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. + * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o); +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. + * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o); +bool CResult_UntrustedStringDecodeErrorZ_is_ok(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. + * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. */ -void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res); +void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); /** - * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` + * Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_clone(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + * Creates a new CResult_PaymentIdPaymentErrorZ in the success state. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + * Creates a new CResult_PaymentIdPaymentErrorZ in the error state. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + * Frees any resources used by the CResult_PaymentIdPaymentErrorZ. */ -void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); +void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + * Creates a new CResult_NonePaymentErrorZ in the success state. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); +struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_ok(void); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + * Creates a new CResult_NonePaymentErrorZ in the error state. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_err(struct LDKPaymentError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); +bool CResult_NonePaymentErrorZ_is_ok(const struct LDKCResult_NonePaymentErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + * Frees any resources used by the CResult_NonePaymentErrorZ. */ -void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); +void CResult_NonePaymentErrorZ_free(struct LDKCResult_NonePaymentErrorZ _res); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_clone(const struct LDKCResult_NonePaymentErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + * Creates a new CResult_StringErrorZ in the success state. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKStr o); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + * Creates a new CResult_StringErrorZ in the error state. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); +bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + * Frees any resources used by the CResult_StringErrorZ. */ -void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); +void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_StringErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_StringErrorZ CResult_StringErrorZ_clone(const struct LDKCResult_StringErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. + * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); /** - * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. + * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_err(enum LDKUtxoLookupError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxOutUtxoLookupErrorZ_is_ok(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. + * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. */ -void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res); +void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); /** - * Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_clone(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_OnionMessagePathNoneZ in the success state. */ -void CVec_ChannelMonitorZ_free(struct LDKCVec_ChannelMonitorZ _res); +struct LDKCResult_OnionMessagePathNoneZ CResult_OnionMessagePathNoneZ_ok(struct LDKOnionMessagePath o); /** - * Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. + * Creates a new CResult_OnionMessagePathNoneZ in the error state. */ -struct LDKC2Tuple_BlockHashChannelManagerZ C2Tuple_BlockHashChannelManagerZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelManager b); +struct LDKCResult_OnionMessagePathNoneZ CResult_OnionMessagePathNoneZ_err(void); /** - * Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. + * Checks if the given object is currently in the success state */ -void C2Tuple_BlockHashChannelManagerZ_free(struct LDKC2Tuple_BlockHashChannelManagerZ _res); +bool CResult_OnionMessagePathNoneZ_is_ok(const struct LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. + * Frees any resources used by the CResult_OnionMessagePathNoneZ. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelManagerZ o); +void CResult_OnionMessagePathNoneZ_free(struct LDKCResult_OnionMessagePathNoneZ _res); /** - * Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. + * Creates a new CResult_OnionMessagePathNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_OnionMessagePathNoneZ CResult_OnionMessagePathNoneZ_clone(const struct LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneSendErrorZ in the success state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); + +/** + * Creates a new CResult_NoneSendErrorZ in the error state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o); +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. + * Frees any resources used by the CResult_NoneSendErrorZ. */ -void CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res); +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. + * Creates a new CResult_BlindedPathNoneZ in the success state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_ok(struct LDKBlindedPath o); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. + * Creates a new CResult_BlindedPathNoneZ in the error state. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelConfigDecodeErrorZ_is_ok(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR o); +bool CResult_BlindedPathNoneZ_is_ok(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. + * Frees any resources used by the CResult_BlindedPathNoneZ. */ -void CResult_ChannelConfigDecodeErrorZ_free(struct LDKCResult_ChannelConfigDecodeErrorZ _res); +void CResult_BlindedPathNoneZ_free(struct LDKCResult_BlindedPathNoneZ _res); /** - * Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_clone(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_clone(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR orig); /** - * Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError + * Creates a new CResult_BlindedPathDecodeErrorZ in the success state. */ -struct LDKCOption_APIErrorZ COption_APIErrorZ_some(struct LDKAPIError o); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); /** - * Constructs a new COption_APIErrorZ containing nothing + * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. */ -struct LDKCOption_APIErrorZ COption_APIErrorZ_none(void); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state + * Checks if the given object is currently in the success state */ -void COption_APIErrorZ_free(struct LDKCOption_APIErrorZ _res); +bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new COption_APIErrorZ which has the same data as `orig` + * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. + */ +void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_APIErrorZ COption_APIErrorZ_clone(const struct LDKCOption_APIErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. */ -struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_ok(struct LDKCOption_APIErrorZ o); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); /** - * Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. */ -struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_COption_APIErrorZDecodeErrorZ_is_ok(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR o); +bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. + * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. */ -void CResult_COption_APIErrorZDecodeErrorZ_free(struct LDKCResult_COption_APIErrorZDecodeErrorZ _res); +void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); /** - * Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_clone(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. + * Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_ok(struct LDKInvoiceError o); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. + * Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_UntrustedStringDecodeErrorZ_is_ok(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR o); +bool CResult_InvoiceErrorDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. + * Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. */ -void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); +void CResult_InvoiceErrorDecodeErrorZ_free(struct LDKCResult_InvoiceErrorDecodeErrorZ _res); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_clone(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_clone(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_OutPointDecodeErrorZ in the success state. + * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LDKOutPoint o); +struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); /** - * Creates a new CResult_OutPointDecodeErrorZ in the error state. + * Constructs a new COption_FilterZ containing nothing */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_FilterZ COption_FilterZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state */ -bool CResult_OutPointDecodeErrorZ_is_ok(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR o); +void COption_FilterZ_free(struct LDKCOption_FilterZ _res); /** - * Frees any resources used by the CResult_OutPointDecodeErrorZ. + * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. */ -void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _res); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); /** - * Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. */ -struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); /** - * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type + * Checks if the given object is currently in the success state */ -struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o); +bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); /** - * Constructs a new COption_TypeZ containing nothing + * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. */ -struct LDKCOption_TypeZ COption_TypeZ_none(void); +void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); /** - * Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void COption_TypeZ_free(struct LDKCOption_TypeZ _res); +void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); /** - * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o); +void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); /** - * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. */ -bool CResult_COption_TypeZDecodeErrorZ_is_ok(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR o); +struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); /** - * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. + * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. */ -void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res); +void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); /** - * Creates a new CResult_PaymentIdPaymentErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struct LDKThirtyTwoBytes o); +void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); /** - * Creates a new CResult_PaymentIdPaymentErrorZ in the error state. + * Frees any resources used by the APIError */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e); +void APIError_free(struct LDKAPIError this_ptr); /** - * Checks if the given object is currently in the success state + * Creates a copy of the APIError */ -bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o); +struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_PaymentIdPaymentErrorZ. + * Utility method to constructs a new APIMisuseError-variant APIError */ -void CResult_PaymentIdPaymentErrorZ_free(struct LDKCResult_PaymentIdPaymentErrorZ _res); +struct LDKAPIError APIError_apimisuse_error(struct LDKStr err); /** - * Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new FeeRateTooHigh-variant APIError */ -struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_clone(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR orig); +struct LDKAPIError APIError_fee_rate_too_high(struct LDKStr err, uint32_t feerate); /** - * Creates a new CResult_NonePaymentErrorZ in the success state. + * Utility method to constructs a new InvalidRoute-variant APIError */ -struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_ok(void); +struct LDKAPIError APIError_invalid_route(struct LDKStr err); /** - * Creates a new CResult_NonePaymentErrorZ in the error state. + * Utility method to constructs a new ChannelUnavailable-variant APIError */ -struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_err(struct LDKPaymentError e); +struct LDKAPIError APIError_channel_unavailable(struct LDKStr err); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new MonitorUpdateInProgress-variant APIError */ -bool CResult_NonePaymentErrorZ_is_ok(const struct LDKCResult_NonePaymentErrorZ *NONNULL_PTR o); +struct LDKAPIError APIError_monitor_update_in_progress(void); /** - * Frees any resources used by the CResult_NonePaymentErrorZ. + * Utility method to constructs a new IncompatibleShutdownScript-variant APIError */ -void CResult_NonePaymentErrorZ_free(struct LDKCResult_NonePaymentErrorZ _res); +struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script); /** - * Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two APIErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_NonePaymentErrorZ CResult_NonePaymentErrorZ_clone(const struct LDKCResult_NonePaymentErrorZ *NONNULL_PTR orig); +bool APIError_eq(const struct LDKAPIError *NONNULL_PTR a, const struct LDKAPIError *NONNULL_PTR b); /** - * Creates a new CResult_StringErrorZ in the success state. + * Serialize the APIError object into a byte array which can be read by APIError_read */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKStr o); +struct LDKCVec_u8Z APIError_write(const struct LDKAPIError *NONNULL_PTR obj); /** - * Creates a new CResult_StringErrorZ in the error state. + * Read a APIError from a byte array, created by APIError_write */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_COption_APIErrorZDecodeErrorZ APIError_read(struct LDKu8slice ser); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the BigSize, if is_owned is set and inner is non-NULL. */ -bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o); +void BigSize_free(struct LDKBigSize this_obj); -/** - * Frees any resources used by the CResult_StringErrorZ. - */ -void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); +uint64_t BigSize_get_a(const struct LDKBigSize *NONNULL_PTR this_ptr); + +void BigSize_set_a(struct LDKBigSize *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_StringErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new BigSize given each field */ -struct LDKCResult_StringErrorZ CResult_StringErrorZ_clone(const struct LDKCResult_StringErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKBigSize BigSize_new(uint64_t a_arg); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. + * Creates a copy of the BigSize */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_ok(struct LDKChannelMonitorUpdate o); +struct LDKBigSize BigSize_clone(const struct LDKBigSize *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. + * Generates a non-cryptographic 64-bit hash of the BigSize. */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t BigSize_hash(const struct LDKBigSize *NONNULL_PTR o); /** - * Checks if the given object is currently in the success state + * Checks if two BigSizes 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. */ -bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o); +bool BigSize_eq(const struct LDKBigSize *NONNULL_PTR a, const struct LDKBigSize *NONNULL_PTR b); /** - * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. + * Serialize the BigSize object into a byte array which can be read by BigSize_read */ -void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res); +struct LDKCVec_u8Z BigSize_write(const struct LDKBigSize *NONNULL_PTR obj); /** - * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Read a BigSize from a byte array, created by BigSize_write */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BigSizeDecodeErrorZ BigSize_read(struct LDKu8slice ser); /** - * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent + * Frees any resources used by the Hostname, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o); +void Hostname_free(struct LDKHostname this_obj); /** - * Constructs a new COption_MonitorEventZ containing nothing + * Creates a copy of the Hostname */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void); +struct LDKHostname Hostname_clone(const struct LDKHostname *NONNULL_PTR orig); /** - * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state + * Checks if two Hostnames 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. */ -void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res); +bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostname *NONNULL_PTR b); /** - * Creates a new COption_MonitorEventZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Returns the length of the hostname. */ -struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig); +MUST_USE_RES uint8_t Hostname_len(const struct LDKHostname *NONNULL_PTR this_arg); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. + * Serialize the Hostname object into a byte array which can be read by Hostname_read */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o); +struct LDKCVec_u8Z Hostname_write(const struct LDKHostname *NONNULL_PTR obj); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. + * Read a Hostname from a byte array, created by Hostname_write */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_HostnameDecodeErrorZ Hostname_read(struct LDKu8slice ser); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the TransactionU16LenLimited, if is_owned is set and inner is non-NULL. */ -bool CResult_COption_MonitorEventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR o); +void TransactionU16LenLimited_free(struct LDKTransactionU16LenLimited this_obj); /** - * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. + * Creates a copy of the TransactionU16LenLimited */ -void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res); +struct LDKTransactionU16LenLimited TransactionU16LenLimited_clone(const struct LDKTransactionU16LenLimited *NONNULL_PTR orig); /** - * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two TransactionU16LenLimiteds 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. */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig); +bool TransactionU16LenLimited_eq(const struct LDKTransactionU16LenLimited *NONNULL_PTR a, const struct LDKTransactionU16LenLimited *NONNULL_PTR b); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + * Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus- + * serialized length is <= u16::MAX. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); +MUST_USE_RES struct LDKCResult_TransactionU16LenLimitedNoneZ TransactionU16LenLimited_new(struct LDKTransaction transaction); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + * Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKTransaction TransactionU16LenLimited_into_transaction(struct LDKTransactionU16LenLimited this_arg); /** - * Checks if the given object is currently in the success state + * Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read */ -bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o); +struct LDKCVec_u8Z TransactionU16LenLimited_write(const struct LDKTransactionU16LenLimited *NONNULL_PTR obj); /** - * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + * Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write */ -void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); +struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ TransactionU16LenLimited_read(struct LDKu8slice ser); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a digital signature of a message given a SecretKey, like the node's secret. + * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. + * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Recovers the PublicKey of the signer of the message given the message and the signature. */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const struct LDKC2Tuple_OutPointScriptZ *NONNULL_PTR orig); +struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); /** - * Creates a new C2Tuple_OutPointScriptZ from the contained elements. + * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, + * and the PublicKey. */ -struct LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(struct LDKOutPoint a, struct LDKCVec_u8Z b); +bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); /** - * Frees any resources used by the C2Tuple_OutPointScriptZ. + * Construct the invoice's HRP and signatureless data into a preimage to be hashed. */ -void C2Tuple_OutPointScriptZ_free(struct LDKC2Tuple_OutPointScriptZ _res); +struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z data_without_signature); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_clone(const struct LDKC2Tuple_u32ScriptZ *NONNULL_PTR orig); +void Persister_free(struct LDKPersister this_ptr); /** - * Creates a new C2Tuple_u32ScriptZ from the contained elements. + * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. */ -struct LDKC2Tuple_u32ScriptZ C2Tuple_u32ScriptZ_new(uint32_t a, struct LDKCVec_u8Z b); +void UntrustedString_free(struct LDKUntrustedString this_obj); + +struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); + +void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Frees any resources used by the C2Tuple_u32ScriptZ. + * Constructs a new UntrustedString given each field */ -void C2Tuple_u32ScriptZ_free(struct LDKC2Tuple_u32ScriptZ _res); +MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a copy of the UntrustedString */ -void CVec_C2Tuple_u32ScriptZZ_free(struct LDKCVec_C2Tuple_u32ScriptZZ _res); +struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two UntrustedStrings 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. */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR orig); +bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. + * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32ScriptZZ b); +struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. + * Read a UntrustedString from a byte array, created by UntrustedString_write */ -void C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res); +struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. */ -void CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res); +void PrintableString_free(struct LDKPrintableString this_obj); + +struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); + +void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new PrintableString given each field */ -void CVec_EventZ_free(struct LDKCVec_EventZ _res); +MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Calls the free function if one is set */ -void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +void FutureCallback_free(struct LDKFutureCallback this_ptr); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the Future, if is_owned is set and inner is non-NULL. */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const struct LDKC2Tuple_u32TxOutZ *NONNULL_PTR orig); +void Future_free(struct LDKFuture this_obj); /** - * Creates a new C2Tuple_u32TxOutZ from the contained elements. + * Creates a copy of the Future */ -struct LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_new(uint32_t a, struct LDKTxOut b); +struct LDKFuture Future_clone(const struct LDKFuture *NONNULL_PTR orig); /** - * Frees any resources used by the C2Tuple_u32TxOutZ. + * Registers a callback to be called upon completion of this future. If the future has already + * completed, the callback will be called immediately. */ -void C2Tuple_u32TxOutZ_free(struct LDKC2Tuple_u32TxOutZ _res); +void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Waits until this [`Future`] completes. */ -void CVec_C2Tuple_u32TxOutZZ_free(struct LDKCVec_C2Tuple_u32TxOutZZ _res); +void Future_wait(struct LDKFuture this_arg); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Waits until this [`Future`] completes or the given amount of time has elapsed. + * + * Returns true if the [`Future`] completed, false if the time elapsed. */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR orig); +MUST_USE_RES bool Future_wait_timeout(struct LDKFuture this_arg, uint64_t max_wait); /** - * Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. + * Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL. */ -struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(struct LDKThirtyTwoBytes a, struct LDKCVec_C2Tuple_u32TxOutZZ b); +void Sleeper_free(struct LDKSleeper this_obj); /** - * Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. + * Constructs a new sleeper from one future, allowing blocking on it. */ -void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res); +MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(struct LDKFuture future); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new sleeper from two futures, allowing blocking on both at once. */ -void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); +MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(struct LDKFuture fut_a, struct LDKFuture fut_b); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new sleeper on many futures, allowing blocking on all at once. */ -void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); +MUST_USE_RES struct LDKSleeper Sleeper_new(struct LDKCVec_FutureZ futures); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. + * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed. */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(struct LDKC2Tuple_BlockHashChannelMonitorZ o); +void Sleeper_wait(const struct LDKSleeper *NONNULL_PTR this_arg); /** - * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. + * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the + * given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time + * elapsed. */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES bool Sleeper_wait_timeout(const struct LDKSleeper *NONNULL_PTR this_arg, uint64_t max_wait); /** - * Checks if the given object is currently in the success state + * Creates a copy of the Level */ -bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o); +enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. + * Utility method to constructs a new Gossip-variant Level */ -void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res); +enum LDKLevel Level_gossip(void); /** - * Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. + * Utility method to constructs a new Trace-variant Level */ -struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b); +enum LDKLevel Level_trace(void); /** - * Frees any resources used by the C2Tuple_PublicKeyTypeZ. + * Utility method to constructs a new Debug-variant Level */ -void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res); +enum LDKLevel Level_debug(void); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Utility method to constructs a new Info-variant Level */ -void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res); +enum LDKLevel Level_info(void); /** - * Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents + * Utility method to constructs a new Warn-variant Level */ -struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_some(struct LDKCustomOnionMessageContents o); +enum LDKLevel Level_warn(void); /** - * Constructs a new COption_CustomOnionMessageContentsZ containing nothing + * Utility method to constructs a new Error-variant Level */ -struct LDKCOption_CustomOnionMessageContentsZ COption_CustomOnionMessageContentsZ_none(void); +enum LDKLevel Level_error(void); /** - * Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state + * Checks if two Levels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void COption_CustomOnionMessageContentsZ_free(struct LDKCOption_CustomOnionMessageContentsZ _res); +bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); /** - * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. + * Generates a non-cryptographic 64-bit hash of the Level. */ -struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(struct LDKCOption_CustomOnionMessageContentsZ o); +uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); /** - * Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. + * Returns the most verbose logging level. */ -struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES enum LDKLevel Level_max(void); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the Record, if is_owned is set and inner is non-NULL. */ -bool CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR o); +void Record_free(struct LDKRecord this_obj); /** - * Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. + * The verbosity level of the message. */ -void CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(struct LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res); +enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress + * The verbosity level of the message. */ -struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o); +void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val); /** - * Constructs a new COption_NetAddressZ containing nothing + * The message body. */ -struct LDKCOption_NetAddressZ COption_NetAddressZ_none(void); +struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state + * The message body. */ -void COption_NetAddressZ_free(struct LDKCOption_NetAddressZ _res); +void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Creates a new COption_NetAddressZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The module path of the message. */ -struct LDKCOption_NetAddressZ COption_NetAddressZ_clone(const struct LDKCOption_NetAddressZ *NONNULL_PTR orig); +struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The module path of the message. */ -struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ C2Tuple_PublicKeyCOption_NetAddressZZ_clone(const struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR orig); +void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. + * The source file containing the message. */ -struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ C2Tuple_PublicKeyCOption_NetAddressZZ_new(struct LDKPublicKey a, struct LDKCOption_NetAddressZ b); +struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. + * The source file containing the message. */ -void C2Tuple_PublicKeyCOption_NetAddressZZ_free(struct LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res); +void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The line containing the message. */ -void CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res); +uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. + * The line containing the message. */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(struct LDKCVec_u8Z o); +void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. + * Creates a copy of the Record */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o); +void Logger_free(struct LDKLogger this_ptr); /** - * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. + * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. */ -void CResult_CVec_u8ZPeerHandleErrorZ_free(struct LDKCResult_CVec_u8ZPeerHandleErrorZ _res); +void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** - * Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * + * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ -struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_clone(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR orig); +uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NonePeerHandleErrorZ in the success state. + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * + * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); +void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_NonePeerHandleErrorZ in the error state. + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); +uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. */ -bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); +void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the CResult_NonePeerHandleErrorZ. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); +uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); +void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_boolPeerHandleErrorZ in the success state. + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); +uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_boolPeerHandleErrorZ in the error state. + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint8_t val); /** - * Checks if the given object is currently in the success state + * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the + * BOLTs) option for outbound private channels. This provides better privacy by not including + * our real on-chain channel UTXO in each invoice and requiring that our counterparty only + * relay HTLCs to us using the channel's SCID alias. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a + * [`DecodeError::InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `scid_alias` option; we will simply fall back to a + * private channel without that option. + * + * Ignored if the channel is negotiated to be announced, see + * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue */ -bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); +bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_boolPeerHandleErrorZ. + * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the + * BOLTs) option for outbound private channels. This provides better privacy by not including + * our real on-chain channel UTXO in each invoice and requiring that our counterparty only + * relay HTLCs to us using the channel's SCID alias. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a + * [`DecodeError::InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `scid_alias` option; we will simply fall back to a + * private channel without that option. + * + * Ignored if the channel is negotiated to be announced, see + * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue */ -void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); +void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); +void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_err(enum LDKUtxoLookupError e); +bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ -bool CResult_TxOutUtxoLookupErrorZ_is_ok(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR o); +void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. */ -void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); +uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); +void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_NoneSendErrorZ in the success state. + * If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future + * channels. This feature requires having a reserve of onchain funds readily available to bump + * transactions in the event of a channel force close to avoid the possibility of losing funds. + * + * Note that if you wish accept inbound channels with anchor outputs, you must enable + * [`UserConfig::manually_accept_inbound_channels`] and manually accept them with + * [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check + * whether your reserve of onchain funds is enough to cover the fees for all existing and new + * channels featuring anchor outputs in the event of a force close. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.116, causing [`ChannelManager`]'s read method to return a + * [`DecodeError::InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply + * fall back to a `static_remote_key` channel. + * + * LDK will not support the legacy `option_anchors` commitment version due to a discovered + * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee + * Considered Harmful`] mailing list post. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html */ -struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); +bool ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NoneSendErrorZ in the error state. + * If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future + * channels. This feature requires having a reserve of onchain funds readily available to bump + * transactions in the event of a channel force close to avoid the possibility of losing funds. + * + * Note that if you wish accept inbound channels with anchor outputs, you must enable + * [`UserConfig::manually_accept_inbound_channels`] and manually accept them with + * [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check + * whether your reserve of onchain funds is enough to cover the fees for all existing and new + * channels featuring anchor outputs in the event of a force close. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.116, causing [`ChannelManager`]'s read method to return a + * [`DecodeError::InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply + * fall back to a `static_remote_key` channel. + * + * LDK will not support the legacy `option_anchors` commitment version due to a discovered + * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee + * Considered Harmful`] mailing list post. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html */ -struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); +void ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** - * Checks if the given object is currently in the success state + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. */ -bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); +uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_NoneSendErrorZ. + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. */ -void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); +void ChannelHandshakeConfig_set_our_max_accepted_htlcs(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_BlindedPathNoneZ in the success state. + * Constructs a new ChannelHandshakeConfig given each field */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_ok(struct LDKBlindedPath o); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg, bool negotiate_anchors_zero_fee_htlc_tx_arg, uint16_t our_max_accepted_htlcs_arg); /** - * Creates a new CResult_BlindedPathNoneZ in the error state. + * Creates a copy of the ChannelHandshakeConfig */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_err(void); +struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. */ -bool CResult_BlindedPathNoneZ_is_ok(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR o); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); /** - * Frees any resources used by the CResult_BlindedPathNoneZ. + * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. */ -void CResult_BlindedPathNoneZ_free(struct LDKCResult_BlindedPathNoneZ _res); +void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); /** - * Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_clone(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR orig); +uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_BlindedPathDecodeErrorZ in the success state. + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 0. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); +void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); +uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. */ -bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); +void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); +uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows + * you to limit the maximum minimum-size they can require. + * + * Default value: u64::max_value. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); +uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. + * The remote node sets a limit on the maximum value of pending HTLCs to them at any given + * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if the given object is currently in the success state + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); +uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. + * The remote node will require we keep a certain amount in direct payment to ourselves at all + * time, ensuring that we are able to be punished if we broadcast an old state. This allows to + * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). + * + * Default value: u64::max_value. */ -void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); +void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); +uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SiPrefixParseErrorZ in the success state. + * The remote node sets a limit on the maximum number of pending HTLCs to them at any given + * time. This allows you to set a minimum such value. + * + * Default value: 0. */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_ok(enum LDKSiPrefix o); +void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_SiPrefixParseErrorZ in the error state. + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_err(struct LDKParseError e); +uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Before a channel is usable the funding transaction will need to be confirmed by at least a + * certain number of blocks, specified by the node which is not the funder (as the funder can + * assume they aren't going to double-spend themselves). + * This config allows you to set a limit on the maximum amount of time to wait. + * + * Default value: 144, or roughly one day and only applies to outbound channels. */ -bool CResult_SiPrefixParseErrorZ_is_ok(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR o); +void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the CResult_SiPrefixParseErrorZ. + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). + * + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true */ -void CResult_SiPrefixParseErrorZ_free(struct LDKCResult_SiPrefixParseErrorZ _res); +bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). + * + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_clone(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR orig); +void ChannelHandshakeLimits_set_trust_own_funding_0conf(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_ok(struct LDKInvoice o); +bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); +void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** - * Checks if the given object is currently in the success state + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -bool CResult_InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); +uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. + * Set to the amount of time we're willing to wait to claim money back to us. + * + * Not checking this value would be a security issue, as our peer would be able to set it to + * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. + * + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ -void CResult_InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_InvoiceParseOrSemanticErrorZ _res); +void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new ChannelHandshakeLimits given each field */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint32_t max_minimum_depth_arg, bool trust_own_funding_0conf_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); /** - * Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. + * Creates a copy of the ChannelHandshakeLimits */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_ok(struct LDKSignedRawInvoice o); +struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); /** - * Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. + * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_err(struct LDKParseError e); +MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the MaxDustHTLCExposure */ -bool CResult_SignedRawInvoiceParseErrorZ_is_ok(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR o); +void MaxDustHTLCExposure_free(struct LDKMaxDustHTLCExposure this_ptr); /** - * Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. + * Creates a copy of the MaxDustHTLCExposure */ -void CResult_SignedRawInvoiceParseErrorZ_free(struct LDKCResult_SignedRawInvoiceParseErrorZ _res); +struct LDKMaxDustHTLCExposure MaxDustHTLCExposure_clone(const struct LDKMaxDustHTLCExposure *NONNULL_PTR orig); /** - * Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_clone(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR orig); +struct LDKMaxDustHTLCExposure MaxDustHTLCExposure_fixed_limit_msat(uint64_t a); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR orig); +struct LDKMaxDustHTLCExposure MaxDustHTLCExposure_fee_rate_multiplier(uint64_t a); /** - * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. + * Checks if two MaxDustHTLCExposures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); +bool MaxDustHTLCExposure_eq(const struct LDKMaxDustHTLCExposure *NONNULL_PTR a, const struct LDKMaxDustHTLCExposure *NONNULL_PTR b); /** - * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. + * Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read */ -void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); +struct LDKCVec_u8Z MaxDustHTLCExposure_write(const struct LDKMaxDustHTLCExposure *NONNULL_PTR obj); /** - * Creates a new CResult_PayeePubKeyErrorZ in the success state. + * Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); +struct LDKCResult_MaxDustHTLCExposureDecodeErrorZ MaxDustHTLCExposure_read(struct LDKu8slice ser); /** - * Creates a new CResult_PayeePubKeyErrorZ in the error state. + * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); +void ChannelConfig_free(struct LDKChannelConfig this_obj); /** - * Checks if the given object is currently in the success state + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); +uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_PayeePubKeyErrorZ. + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * Default value: 0. */ -void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); +void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); +uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ -void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); +void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); +uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. + * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over + * the channel this config applies to. + * + * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight + * HTLC balance when a channel appears on-chain whereas + * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining + * (non-HTLC-encumbered) balance. + * + * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, + * we (or one of our watchtowers) MUST be online to check for broadcast of the current + * commitment transaction at least once per this many blocks (minus some margin to allow us + * enough time to broadcast and confirm a transaction, possibly with time in between to RBF + * the spending transaction). + * + * Default value: 72 (12 hours at an average of 6 blocks/hour). + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * + * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); +void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Checks if the given object is currently in the success state + * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too + * small to claim on-chain. + * + * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will + * not be claimable on-chain, instead being turned into additional miner fees if either + * party force-closes the channel. Because the threshold is per-HTLC, our total exposure + * to such payments may be sustantial if there are many dust HTLCs present when the + * channel is force-closed. + * + * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a + * channel negotiated throughout the channel open process, along with the fees required to have + * a broadcastable HTLC spending transaction. When a channel supports anchor outputs + * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into + * account the HTLC transaction fee as it is zero. Because of this, you may want to set this + * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier + * variant is primarily intended for use with pre-anchor channels. + * + * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. + * + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. */ -bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); +struct LDKMaxDustHTLCExposure ChannelConfig_get_max_dust_htlc_exposure(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. + * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too + * small to claim on-chain. + * + * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will + * not be claimable on-chain, instead being turned into additional miner fees if either + * party force-closes the channel. Because the threshold is per-HTLC, our total exposure + * to such payments may be sustantial if there are many dust HTLCs present when the + * channel is force-closed. + * + * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a + * channel negotiated throughout the channel open process, along with the fees required to have + * a broadcastable HTLC spending transaction. When a channel supports anchor outputs + * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into + * account the HTLC transaction fee as it is zero. Because of this, you may want to set this + * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier + * variant is primarily intended for use with pre-anchor channels. + * + * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. + * + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. */ -void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); +void ChannelConfig_set_max_dust_htlc_exposure(struct LDKChannelConfig *NONNULL_PTR this_ptr, struct LDKMaxDustHTLCExposure val); /** - * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The additional fee we're willing to pay to avoid waiting for the counterparty's + * `to_self_delay` to reclaim funds. + * + * When we close a channel cooperatively with our counterparty, we negotiate a fee for the + * closing transaction which both sides find acceptable, ultimately paid by the channel + * funder/initiator. + * + * When we are the funder, because we have to pay the channel closing fee, we bound the + * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by + * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our + * [`Normal`] feerate during normal operation, this value represents the additional fee we're + * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our + * funds. + * + * When we are not the funder, we require the closing transaction fee pay at least our + * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. + * Thus, this value is ignored when we are not the funder. + * + * Default value: 1000 satoshis. + * + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); +uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NoneSemanticErrorZ in the success state. + * The additional fee we're willing to pay to avoid waiting for the counterparty's + * `to_self_delay` to reclaim funds. + * + * When we close a channel cooperatively with our counterparty, we negotiate a fee for the + * closing transaction which both sides find acceptable, ultimately paid by the channel + * funder/initiator. + * + * When we are the funder, because we have to pay the channel closing fee, we bound the + * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by + * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our + * [`Normal`] feerate during normal operation, this value represents the additional fee we're + * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our + * funds. + * + * When we are not the funder, we require the closing transaction fee pay at least our + * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. + * Thus, this value is ignored when we are not the funder. + * + * Default value: 1000 satoshis. + * + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); +void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_NoneSemanticErrorZ in the error state. + * If set, allows this channel's counterparty to skim an additional fee off this node's inbound + * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + * + * Usage: + * - The payee will set this option and set its invoice route hints to use [intercept scids] + * generated by this channel's counterparty. + * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call + * [`forward_intercepted_htlc`] with less than the amount provided in + * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and + * actual forward amounts is their fee. + * + * # Note + * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is + * as-expected if this feature is activated, otherwise they may lose money! + * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the + * counterparty. + * + * # Note + * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. + * Unsetting this flag between restarts may lead to payment receive failures. + * + * Default value: false. + * + * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat + * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); +bool ChannelConfig_get_accept_underpaying_htlcs(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * If set, allows this channel's counterparty to skim an additional fee off this node's inbound + * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + * + * Usage: + * - The payee will set this option and set its invoice route hints to use [intercept scids] + * generated by this channel's counterparty. + * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call + * [`forward_intercepted_htlc`] with less than the amount provided in + * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and + * actual forward amounts is their fee. + * + * # Note + * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is + * as-expected if this feature is activated, otherwise they may lose money! + * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the + * counterparty. + * + * # Note + * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. + * Unsetting this flag between restarts may lead to payment receive failures. + * + * Default value: false. + * + * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat + * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat */ -bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); +void ChannelConfig_set_accept_underpaying_htlcs(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_NoneSemanticErrorZ. + * Constructs a new ChannelConfig given each field */ -void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, struct LDKMaxDustHTLCExposure max_dust_htlc_exposure_arg, uint64_t force_close_avoidance_max_fee_satoshis_arg, bool accept_underpaying_htlcs_arg); /** - * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the ChannelConfig */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); +struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceSemanticErrorZ in the success state. + * Checks if two ChannelConfigs 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. */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); +bool ChannelConfig_eq(const struct LDKChannelConfig *NONNULL_PTR a, const struct LDKChannelConfig *NONNULL_PTR b); /** - * Creates a new CResult_InvoiceSemanticErrorZ in the error state. + * Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`]. */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); +void ChannelConfig_apply(struct LDKChannelConfig *NONNULL_PTR this_arg, const struct LDKChannelConfigUpdate *NONNULL_PTR update); /** - * Checks if the given object is currently in the success state + * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */ -bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); /** - * Frees any resources used by the CResult_InvoiceSemanticErrorZ. + * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read */ -void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); +struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); /** - * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Read a ChannelConfig from a byte array, created by ChannelConfig_write */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_clone(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the ChannelConfigUpdate, if is_owned is set and inner is non-NULL. */ -void CVec_AddressZ_free(struct LDKCVec_AddressZ _res); +void ChannelConfigUpdate_free(struct LDKChannelConfigUpdate this_obj); -/** - * Creates a new CResult_DescriptionCreationErrorZ in the success state. - */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); +struct LDKCOption_u32Z ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr); -/** - * Creates a new CResult_DescriptionCreationErrorZ in the error state. - */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); +void ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); -/** - * Checks if the given object is currently in the success state - */ -bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); +struct LDKCOption_u32Z ChannelConfigUpdate_get_forwarding_fee_base_msat(const struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr); -/** - * Frees any resources used by the CResult_DescriptionCreationErrorZ. - */ -void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); +void ChannelConfigUpdate_set_forwarding_fee_base_msat(struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); -/** - * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); +struct LDKCOption_u16Z ChannelConfigUpdate_get_cltv_expiry_delta(const struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr); -/** - * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. - */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); +void ChannelConfigUpdate_set_cltv_expiry_delta(struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); /** - * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. + * + * Returns a copy of the field. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); +struct LDKCOption_MaxDustHTLCExposureZ ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(const struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr); -/** - * Checks if the given object is currently in the success state - */ -bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); +void ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr, struct LDKCOption_MaxDustHTLCExposureZ val); -/** - * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. - */ -void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); +struct LDKCOption_u64Z ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr); + +void ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfigUpdate *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new ChannelConfigUpdate given each field */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelConfigUpdate ChannelConfigUpdate_new(struct LDKCOption_u32Z forwarding_fee_proportional_millionths_arg, struct LDKCOption_u32Z forwarding_fee_base_msat_arg, struct LDKCOption_u16Z cltv_expiry_delta_arg, struct LDKCOption_MaxDustHTLCExposureZ max_dust_htlc_exposure_msat_arg, struct LDKCOption_u64Z force_close_avoidance_max_fee_satoshis_arg); /** - * Creates a new CResult_NetAddressDecodeErrorZ in the success state. + * Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struct LDKNetAddress o); +MUST_USE_RES struct LDKChannelConfigUpdate ChannelConfigUpdate_default(void); /** - * Creates a new CResult_NetAddressDecodeErrorZ in the error state. + * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e); +void UserConfig_free(struct LDKUserConfig this_obj); /** - * Checks if the given object is currently in the success state + * Channel handshake config that we propose to our counterparty. */ -bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o); +struct LDKChannelHandshakeConfig UserConfig_get_channel_handshake_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_NetAddressDecodeErrorZ. + * Channel handshake config that we propose to our counterparty. */ -void CResult_NetAddressDecodeErrorZ_free(struct LDKCResult_NetAddressDecodeErrorZ _res); +void UserConfig_set_channel_handshake_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); /** - * Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Limits applied to our counterparty's proposed channel handshake config settings. */ -struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_clone(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR orig); +struct LDKChannelHandshakeLimits UserConfig_get_channel_handshake_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Limits applied to our counterparty's proposed channel handshake config settings. */ -void CVec_UpdateAddHTLCZ_free(struct LDKCVec_UpdateAddHTLCZ _res); +void UserConfig_set_channel_handshake_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Channel config which affects behavior during channel lifetime. */ -void CVec_UpdateFulfillHTLCZ_free(struct LDKCVec_UpdateFulfillHTLCZ _res); +struct LDKChannelConfig UserConfig_get_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Channel config which affects behavior during channel lifetime. */ -void CVec_UpdateFailHTLCZ_free(struct LDKCVec_UpdateFailHTLCZ _res); +void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. */ -void CVec_UpdateFailMalformedHTLCZ_free(struct LDKCVec_UpdateFailMalformedHTLCZ _res); +bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok(struct LDKAcceptChannel o); +void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); +bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. */ -bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o); +void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel */ -void CResult_AcceptChannelDecodeErrorZ_free(struct LDKCResult_AcceptChannelDecodeErrorZ _res); +bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel */ -struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_clone(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR orig); +void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. + * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC + * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. + * + * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * + * Default value: false. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_ok(struct LDKAnnouncementSignatures o); +bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. + * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC + * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. + * + * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * + * Default value: false. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); +void UserConfig_set_accept_intercept_htlcs(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Checks if the given object is currently in the success state + * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to true, we'll accept the payment. + * + * Setting this to true will break backwards compatibility upon downgrading to an LDK + * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. + * + * Default value: false. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o); +bool UserConfig_get_accept_mpp_keysend(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. + * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to true, we'll accept the payment. + * + * Setting this to true will break backwards compatibility upon downgrading to an LDK + * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. + * + * Default value: false. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -void CResult_AnnouncementSignaturesDecodeErrorZ_free(struct LDKCResult_AnnouncementSignaturesDecodeErrorZ _res); +void UserConfig_set_accept_mpp_keysend(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new UserConfig given each field */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_clone(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig channel_handshake_config_arg, struct LDKChannelHandshakeLimits channel_handshake_limits_arg, struct LDKChannelConfig channel_config_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg, bool accept_intercept_htlcs_arg, bool accept_mpp_keysend_arg); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. + * Creates a copy of the UserConfig */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_ok(struct LDKChannelReestablish o); +struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. + * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKUserConfig UserConfig_default(void); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. */ -bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o); +void BestBlock_free(struct LDKBestBlock this_obj); /** - * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. + * Creates a copy of the BestBlock */ -void CResult_ChannelReestablishDecodeErrorZ_free(struct LDKCResult_ChannelReestablishDecodeErrorZ _res); +struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Checks if two BestBlocks 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. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_clone(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR orig); +bool BestBlock_eq(const struct LDKBestBlock *NONNULL_PTR a, const struct LDKBestBlock *NONNULL_PTR b); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. + * Constructs a `BestBlock` that represents the genesis block at height 0 of the given + * network. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok(struct LDKClosingSigned o); +MUST_USE_RES struct LDKBestBlock BestBlock_from_network(enum LDKNetwork network); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. + * Returns a `BestBlock` as identified by the given block hash and height. */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); /** - * Checks if the given object is currently in the success state + * Returns the best block hash. */ -bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. + * Returns the best block height. */ -void CResult_ClosingSignedDecodeErrorZ_free(struct LDKCResult_ClosingSignedDecodeErrorZ _res); +MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); /** - * Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR orig); +void Listen_free(struct LDKListen this_ptr); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. + * Calls the free function if one is set */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(struct LDKClosingSignedFeeRange o); +void Confirm_free(struct LDKConfirm this_ptr); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. + * Creates a copy of the ChannelMonitorUpdateStatus */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_clone(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new Completed-variant ChannelMonitorUpdateStatus */ -bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_completed(void); /** - * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. + * Utility method to constructs a new InProgress-variant ChannelMonitorUpdateStatus */ -void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_in_progress(void); /** - * Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateStatus */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); +enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_permanent_failure(void); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. + * Checks if two ChannelMonitorUpdateStatuss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_ok(struct LDKCommitmentSigned o); +bool ChannelMonitorUpdateStatus_eq(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR a, const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR b); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. + * Calls the free function if one is set */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); +void Watch_free(struct LDKWatch this_ptr); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o); +void Filter_free(struct LDKFilter this_ptr); /** - * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. + * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. */ -void CResult_CommitmentSignedDecodeErrorZ_free(struct LDKCResult_CommitmentSignedDecodeErrorZ _res); +void WatchedOutput_free(struct LDKWatchedOutput this_obj); /** - * Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * First block where the transaction output may have been spent. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_BlockHashZ WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. + * First block where the transaction output may have been spent. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ok(struct LDKFundingCreated o); +void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCOption_BlockHashZ val); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. + * Outpoint identifying the transaction output. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Outpoint identifying the transaction output. */ -bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o); +void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. + * Spending condition of the transaction output. */ -void CResult_FundingCreatedDecodeErrorZ_free(struct LDKCResult_FundingCreatedDecodeErrorZ _res); +struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); /** - * Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Spending condition of the transaction output. */ -struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_clone(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR orig); +void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the success state. + * Constructs a new WatchedOutput given each field */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok(struct LDKFundingSigned o); +MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKCOption_BlockHashZ block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); /** - * Creates a new CResult_FundingSignedDecodeErrorZ in the error state. + * Creates a copy of the WatchedOutput */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Checks if two WatchedOutputs 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. */ -bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o); +bool WatchedOutput_eq(const struct LDKWatchedOutput *NONNULL_PTR a, const struct LDKWatchedOutput *NONNULL_PTR b); /** - * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. + * Generates a non-cryptographic 64-bit hash of the WatchedOutput. */ -void CResult_FundingSignedDecodeErrorZ_free(struct LDKCResult_FundingSignedDecodeErrorZ _res); +uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); /** - * Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Calls the free function if one is set */ -struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_clone(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR orig); +void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); /** - * Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. + * Creates a copy of the ConfirmationTarget */ -struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_ok(struct LDKChannelReady o); +enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. + * Utility method to constructs a new MempoolMinimum-variant ConfirmationTarget */ -struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKConfirmationTarget ConfirmationTarget_mempool_minimum(void); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new Background-variant ConfirmationTarget */ -bool CResult_ChannelReadyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR o); +enum LDKConfirmationTarget ConfirmationTarget_background(void); /** - * Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. + * Utility method to constructs a new Normal-variant ConfirmationTarget */ -void CResult_ChannelReadyDecodeErrorZ_free(struct LDKCResult_ChannelReadyDecodeErrorZ _res); +enum LDKConfirmationTarget ConfirmationTarget_normal(void); /** - * Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new HighPriority-variant ConfirmationTarget */ -struct LDKCResult_ChannelReadyDecodeErrorZ CResult_ChannelReadyDecodeErrorZ_clone(const struct LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR orig); +enum LDKConfirmationTarget ConfirmationTarget_high_priority(void); /** - * Creates a new CResult_InitDecodeErrorZ in the success state. + * Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o); +uint64_t ConfirmationTarget_hash(const enum LDKConfirmationTarget *NONNULL_PTR o); /** - * Creates a new CResult_InitDecodeErrorZ in the error state. + * Checks if two ConfirmationTargets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); +bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, const enum LDKConfirmationTarget *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o); +void FeeEstimator_free(struct LDKFeeEstimator this_ptr); /** - * Frees any resources used by the CResult_InitDecodeErrorZ. + * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. */ -void CResult_InitDecodeErrorZ_free(struct LDKCResult_InitDecodeErrorZ _res); +void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); /** - * Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the MonitorUpdateId */ -struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_clone(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR orig); +struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the success state. + * Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(struct LDKOpenChannel o); +uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); /** - * Creates a new CResult_OpenChannelDecodeErrorZ in the error state. + * 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. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); +bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Calls the free function if one is set */ -bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o); +void Persist_free(struct LDKPersist this_ptr); /** - * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. + * Frees any resources used by the LockedChannelMonitor, if is_owned is set and inner is non-NULL. */ -void CResult_OpenChannelDecodeErrorZ_free(struct LDKCResult_OpenChannelDecodeErrorZ _res); +void LockedChannelMonitor_free(struct LDKLockedChannelMonitor this_obj); /** - * Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_clone(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR orig); +void ChainMonitor_free(struct LDKChainMonitor this_obj); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. + * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. + * + * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor + * will call back to it indicating transactions and outputs of interest. This allows clients to + * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may + * always need to fetch full blocks absent another means for determining which blocks contain + * transactions relevant to the watched channels. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(struct LDKRevokeAndACK o); +MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. + * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or + * claims which are awaiting confirmation. + * + * Includes the balances from each [`ChannelMonitor`] *except* those included in + * `ignored_channels`, allowing you to filter out balances from channels which are still open + * (and whose balance should likely be pulled from the [`ChannelDetails`]). + * + * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for + * inclusion in the return value. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); /** - * Checks if the given object is currently in the success state + * Gets the [`LockedChannelMonitor`] for a given funding outpoint, returning an `Err` if no + * such [`ChannelMonitor`] is currently being monitored for. + * + * Note that the result holds a mutex over our monitor set, and should not be held + * indefinitely. */ -bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_LockedChannelMonitorNoneZ ChainMonitor_get_monitor(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo); /** - * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. + * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. + * + * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always + * monitoring for on-chain state resolutions. */ -void CResult_RevokeAndACKDecodeErrorZ_free(struct LDKCResult_RevokeAndACKDecodeErrorZ _res); +MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). */ -struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_clone(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the success state. + * Indicates the persistence of a [`ChannelMonitor`] has completed after + * [`ChannelMonitorUpdateStatus::InProgress`] 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 [`ChannelMonitorUpdateStatus::InProgress`], + * 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. */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LDKShutdown o); +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); /** - * Creates a new CResult_ShutdownDecodeErrorZ in the error state. + * Gets a [`Future`] that completes when an event is available either via + * [`chain::Watch::release_pending_monitor_events`] or + * [`EventsProvider::process_pending_events`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChainMonitor`] and should instead register actions to be taken later. + * + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKFuture ChainMonitor_get_update_future(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Checks if the given object is currently in the success state + * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is + * crucial in preventing certain classes of pinning attacks, detecting substantial mempool + * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend + * invoking this every 30 seconds, or lower if running in an environment with spotty + * connections, like on mobile. */ -bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o); +void ChainMonitor_rebroadcast_pending_claims(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_ShutdownDecodeErrorZ. + * 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 */ -void CResult_ShutdownDecodeErrorZ_free(struct LDKCResult_ShutdownDecodeErrorZ _res); +struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_clone(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR orig); +struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. + * Constructs a new Watch which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ok(struct LDKUpdateFailHTLC o); +struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. */ -bool CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o); +void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); /** - * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with two exceptions specified below. + * + * This sequence number is also used to track up to which points updates which returned + * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instances we allow where update_id values are not strictly increasing have a + * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that + * will force close the channel by broadcasting the latest commitment transaction or + * special post-force-close updates, like providing preimages necessary to claim outputs on the + * broadcast commitment transaction. See its docs for more details. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ -void CResult_UpdateFailHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailHTLCDecodeErrorZ _res); +uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); /** - * Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The sequence number of this update. Updates *must* be replayed in-order according to this + * sequence number (and updates may panic if they are not). The update_id values are strictly + * increasing and increase by one for each new update, with two exceptions specified below. + * + * This sequence number is also used to track up to which points updates which returned + * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given + * ChannelMonitor when ChannelManager::channel_monitor_updated is called. + * + * The only instances we allow where update_id values are not strictly increasing have a + * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that + * will force close the channel by broadcasting the latest commitment transaction or + * special post-force-close updates, like providing preimages necessary to claim outputs on the + * broadcast commitment transaction. See its docs for more details. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR orig); +void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. + * Creates a copy of the ChannelMonitorUpdate */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(struct LDKUpdateFailMalformedHTLC o); +struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. + * Checks if two ChannelMonitorUpdates 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. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); +bool ChannelMonitorUpdate_eq(const struct LDKChannelMonitorUpdate *NONNULL_PTR a, const struct LDKChannelMonitorUpdate *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read */ -bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o); +struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); /** - * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. + * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write */ -void CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res); +struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); /** - * Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the MonitorEvent */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR orig); +void MonitorEvent_free(struct LDKMonitorEvent this_ptr); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. + * Creates a copy of the MonitorEvent */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct LDKUpdateFee o); +struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. + * Utility method to constructs a new HTLCEvent-variant MonitorEvent */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent */ -bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o); +struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); /** - * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. + * Utility method to constructs a new Completed-variant MonitorEvent */ -void CResult_UpdateFeeDecodeErrorZ_free(struct LDKCResult_UpdateFeeDecodeErrorZ _res); +struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); /** - * Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new UpdateFailed-variant MonitorEvent */ -struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_clone(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR orig); +struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. + * Checks if two MonitorEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_ok(struct LDKUpdateFulfillHTLC o); +bool MonitorEvent_eq(const struct LDKMonitorEvent *NONNULL_PTR a, const struct LDKMonitorEvent *NONNULL_PTR b); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. + * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj); /** - * Checks if the given object is currently in the success state + * Read a MonitorEvent from a byte array, created by MonitorEvent_write */ -bool CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser); /** - * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. + * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. */ -void CResult_UpdateFulfillHTLCDecodeErrorZ_free(struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res); +void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); /** - * Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the HTLCUpdate */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. + * Checks if two HTLCUpdates 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. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok(struct LDKUpdateAddHTLC o); +bool HTLCUpdate_eq(const struct LDKHTLCUpdate *NONNULL_PTR a, const struct LDKHTLCUpdate *NONNULL_PTR b); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. + * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); /** - * Checks if the given object is currently in the success state + * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write */ -bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o); +struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); /** - * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. + * Frees any resources used by the Balance */ -void CResult_UpdateAddHTLCDecodeErrorZ_free(struct LDKCResult_UpdateAddHTLCDecodeErrorZ _res); +void Balance_free(struct LDKBalance this_ptr); /** - * Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a copy of the Balance */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_clone(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR orig); +struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); /** - * Creates a new CResult_OnionMessageDecodeErrorZ in the success state. + * Utility method to constructs a new ClaimableOnChannelClose-variant Balance */ -struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_ok(struct LDKOnionMessage o); +struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); /** - * Creates a new CResult_OnionMessageDecodeErrorZ in the error state. + * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance */ -struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new ContentiousClaimable-variant Balance */ -bool CResult_OnionMessageDecodeErrorZ_is_ok(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR o); +struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_preimage); /** - * Frees any resources used by the CResult_OnionMessageDecodeErrorZ. + * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance */ -void CResult_OnionMessageDecodeErrorZ_free(struct LDKCResult_OnionMessageDecodeErrorZ _res); +struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t claimable_height, struct LDKThirtyTwoBytes payment_hash); /** - * Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance */ -struct LDKCResult_OnionMessageDecodeErrorZ CResult_OnionMessageDecodeErrorZ_clone(const struct LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR orig); +struct LDKBalance Balance_maybe_preimage_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t expiry_height, struct LDKThirtyTwoBytes payment_hash); /** - * Creates a new CResult_PingDecodeErrorZ in the success state. + * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o); +struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t claimable_amount_satoshis); /** - * Creates a new CResult_PingDecodeErrorZ in the error state. + * Checks if two Balances contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); +bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * The amount claimable, in satoshis. This excludes balances that we are unsure if we are able + * to claim, this is because we are waiting for a preimage or for a timeout to expire. For more + * information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and + * [`Balance::MaybePreimageClaimableHTLC`]. + * + * On-chain fees required to claim the balance are not included in this amount. */ -bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES uint64_t Balance_claimable_amount_satoshis(const struct LDKBalance *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_PingDecodeErrorZ. + * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. */ -void CResult_PingDecodeErrorZ_free(struct LDKCResult_PingDecodeErrorZ _res); +void ChannelMonitor_free(struct LDKChannelMonitor this_obj); /** - * Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read */ -struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_clone(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); /** - * Creates a new CResult_PongDecodeErrorZ in the success state. + * Updates a ChannelMonitor on the basis of some new information provided by the Channel + * itself. + * + * panics if the given update is not the next update by update_id. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); /** - * Creates a new CResult_PongDecodeErrorZ in the error state. + * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this + * ChannelMonitor. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Checks if the given object is currently in the success state + * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. */ -bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_PongDecodeErrorZ. + * Gets a list of txids, with their output scripts (in the order they appear in the + * transaction), which we must learn about spends of via block_connected(). */ -void CResult_PongDecodeErrorZ_free(struct LDKCResult_PongDecodeErrorZ _res); +MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly + * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs + * have been registered. */ -struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_clone(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR orig); +void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. + * Get the list of HTLCs who's status has been updated on chain. This should be called by + * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(struct LDKUnsignedChannelAnnouncement o); +MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. + * Processes [`SpendableOutputs`] events produced from each [`ChannelMonitor`] upon maturity. + * + * For channels featuring anchor outputs, this method will also process [`BumpTransaction`] + * events produced from each [`ChannelMonitor`] while there is a balance to claim onchain + * within each channel. As the confirmation of a commitment transaction may be critical to the + * safety of funds, we recommend invoking this every 30 seconds, or lower if running in an + * environment with spotty connections, like on mobile. + * + * An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in + * order to handle these events. + * + * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs + * [`BumpTransaction`]: crate::events::Event::BumpTransaction */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelMonitor_process_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKEventHandler *NONNULL_PTR handler); /** - * Checks if the given object is currently in the success state + * Gets the `node_id` of the counterparty for this channel. + * + * Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some` + * otherwise. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKPublicKey ChannelMonitor_get_counterparty_node_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. + * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of + * the Channel was out-of-date. + * + * You may also use this to broadcast the latest local commitment transaction, either because + * a monitor update failed with [`ChannelMonitorUpdateStatus::PermanentFailure`] or because we've + * fallen behind (i.e. we've received proof that our counterparty side knows a revocation + * secret we gave them that they shouldn't know). + * + * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty + * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't + * close channel with their commitment transaction after a substantial amount of time. Best + * may be to contact the other node operator out-of-band to coordinate other options available + * to you. In any-case, the choice is up to you. + * + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure */ -void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); +MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); /** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Processes transactions in a newly connected block, which may result in any of the following: + * - update the monitor's state against resolved HTLCs + * - punish the counterparty in the case of seeing a revoked commitment transaction + * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration + * - detect settled outputs for later spending + * - schedule and bump any in-flight claims + * + * Returns any new outputs to watch from `txdata`; after called, these are also included in + * [`get_outputs_to_watch`]. + * + * [`get_outputs_to_watch`]: #method.get_outputs_to_watch */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. + * Determines if the disconnected block contained any transactions of interest and updates + * appropriately. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); +void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. + * Processes transactions confirmed in a block with the given header and height, returning new + * outputs to watch. See [`block_connected`] for details. + * + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Checks if the given object is currently in the success state + * Processes a transaction that was reorganized out of the chain. + * + * Used instead of [`block_disconnected`] by clients that are notified of transactions rather + * than blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_disconnected`]: Self::block_disconnected */ -bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); +void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. + * Updates the monitor with the current best chain tip, returning new outputs to watch. See + * [`block_connected`] for details. + * + * Used instead of [`block_connected`] by clients that are notified of transactions rather than + * blocks. See [`chain::Confirm`] for calling expectations. + * + * [`block_connected`]: Self::block_connected */ -void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); +MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Returns the set of txids that should be monitored for re-organization out of the chain. */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); +MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. + * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is + * crucial in preventing certain classes of pinning attacks, detecting substantial mempool + * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend + * invoking this every 30 seconds, or lower if running in an environment with spotty + * connections, like on mobile. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); /** - * Checks if the given object is currently in the success state + * Gets the balances in this channel which are either claimable by us if we were to + * force-close the channel now or which are claimable on-chain (possibly awaiting + * confirmation). + * + * Any balances in the channel which are available on-chain (excluding on-chain fees) are + * included here until an [`Event::SpendableOutputs`] event has been generated for the + * balance, or until our counterparty has claimed the balance and accrued several + * confirmations on the claim transaction. + * + * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of + * LDK prior to 0.0.111, balances may not be fully captured if our counterparty broadcasted + * a revoked state. + * + * See [`Balance`] for additional details on the types of claimable balances which + * may be returned here and their meanings. */ -bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); +MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. + * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write */ -void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); +struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKEntropySource *NONNULL_PTR arg_a, const struct LDKSignerProvider *NONNULL_PTR arg_b); /** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +void OutPoint_free(struct LDKOutPoint this_obj); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. + * The referenced transaction's txid. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); +const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. + * The referenced transaction's txid. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if the given object is currently in the success state + * The index of the referenced output in its transaction's vout. */ -bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); +uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. + * The index of the referenced output in its transaction's vout. */ -void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); +void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Constructs a new OutPoint given each field */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); +MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. + * Creates a copy of the OutPoint */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); +struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. + * Checks if two OutPoints 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. */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); +bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b); /** - * Checks if the given object is currently in the success state + * Generates a non-cryptographic 64-bit hash of the OutPoint. */ -bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); +uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. + * Convert an `OutPoint` to a lightning channel id. */ -void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); +MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); /** - * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Serialize the OutPoint object into a byte array which can be read by OutPoint_read */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); +struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); /** - * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. + * Read a OutPoint from a byte array, created by OutPoint_write */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); +struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); /** - * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. + * Creates a copy of the FailureCode */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); +enum LDKFailureCode FailureCode_clone(const enum LDKFailureCode *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Utility method to constructs a new TemporaryNodeFailure-variant FailureCode */ -bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); +enum LDKFailureCode FailureCode_temporary_node_failure(void); /** - * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. + * Utility method to constructs a new RequiredNodeFeatureMissing-variant FailureCode */ -void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); +enum LDKFailureCode FailureCode_required_node_feature_missing(void); /** - * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Utility method to constructs a new IncorrectOrUnknownPaymentDetails-variant FailureCode */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); +enum LDKFailureCode FailureCode_incorrect_or_unknown_payment_details(void); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. + * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); +void ChannelManager_free(struct LDKChannelManager this_obj); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. + * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +void ChainParameters_free(struct LDKChainParameters this_obj); /** - * Checks if the given object is currently in the success state + * The network for determining the `chain_hash` in Lightning messages. */ -bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); +enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. + * The network for determining the `chain_hash` in Lightning messages. */ -void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); +void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); /** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The hash and height of the latest block successfully connected. + * + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. + * The hash and height of the latest block successfully connected. + * + * Used to track on-chain channel funding outputs and send payments with reliable timelocks. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); +void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. + * Constructs a new ChainParameters given each field */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); /** - * Checks if the given object is currently in the success state + * Creates a copy of the ChainParameters */ -bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); +struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. + * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. */ -void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); +void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); /** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Base routing fee in millisatoshis. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); +uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. + * Base routing fee in millisatoshis. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); +void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); +uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. */ -bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); +void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. */ -void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); +uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); /** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); +void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. + * Constructs a new CounterpartyForwardingInfo given each field */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); +MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. + * Creates a copy of the CounterpartyForwardingInfo */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. */ -bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); +void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); /** - * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. + * The node_id of our counterparty */ -void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); +struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The node_id of our counterparty */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); +void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); +struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Checks if the given object is currently in the success state + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat */ -bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); +uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat */ -void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); +void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); +void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. */ -bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); +void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. */ -void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); /** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); +void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. + * Constructs a new ChannelCounterparty given each field */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); +MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. + * Creates a copy of the ChannelCounterparty */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); /** - * Checks if the given object is currently in the success state + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. */ -bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); +void ChannelDetails_free(struct LDKChannelDetails this_obj); /** - * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); +const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; /** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Parameters which apply to our counterparty. See individual fields for more information. */ -void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); +struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. + * Parameters which apply to our counterparty. See individual fields for more information. */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_ok(struct LDKInvoice o); +void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that, if this has been set, `channel_id` will be equivalent to + * `funding_txo.unwrap().to_channel_id()`. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); +struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Checks if the given object is currently in the success state + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that, if this has been set, `channel_id` will be equivalent to + * `funding_txo.unwrap().to_channel_id()`. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); +void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCreationErrorZ _res); +struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); +void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required */ -void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); +struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required */ -struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); +void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Constructs a new COption_FilterZ containing nothing + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required */ -struct LDKCOption_FilterZ COption_FilterZ_none(void); +struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required */ -void COption_FilterZ_free(struct LDKCOption_FilterZ _res); +void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); +struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); +void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Checks if the given object is currently in the success state + * The value, in satoshis, of this channel as appears in the funding output */ -bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. + * The value, in satoshis, of this channel as appears in the funding output */ -void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ -void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); +struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ -void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); +void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * The `user_channel_id` passed in to create_channel, or a random value if the channel was + * inbound. This may be zero for inbound channels serialized with LDK versions prior to + * 0.0.113. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); +struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. + * The `user_channel_id` passed in to create_channel, or a random value if the channel was + * inbound. This may be zero for inbound channels serialized with LDK versions prior to + * 0.0.113. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); +void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); /** - * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. */ -void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); +struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. */ -void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); +void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Creates a new CResult_u32GraphSyncErrorZ in the success state. + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); +uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a new CResult_u32GraphSyncErrorZ in the error state. + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); +void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if the given object is currently in the success state + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * See also [`ChannelDetails::balance_msat`] + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. */ -bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CResult_u32GraphSyncErrorZ. + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * See also [`ChannelDetails::balance_msat`] + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. */ -void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the APIError + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], + * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. */ -void APIError_free(struct LDKAPIError this_ptr); +uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a copy of the APIError + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], + * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. */ -struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); +void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new APIMisuseError-variant APIError + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. */ -struct LDKAPIError APIError_apimisuse_error(struct LDKStr err); +uint64_t ChannelDetails_get_next_outbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new FeeRateTooHigh-variant APIError + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. */ -struct LDKAPIError APIError_fee_rate_too_high(struct LDKStr err, uint32_t feerate); +void ChannelDetails_set_next_outbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new InvalidRoute-variant APIError + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ -struct LDKAPIError APIError_invalid_route(struct LDKStr err); +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ChannelUnavailable-variant APIError + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ -struct LDKAPIError APIError_channel_unavailable(struct LDKStr err); +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new MonitorUpdateInProgress-variant APIError + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth */ -struct LDKAPIError APIError_monitor_update_in_progress(void); +struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new IncompatibleShutdownScript-variant APIError + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth */ -struct LDKAPIError APIError_incompatible_shutdown_script(struct LDKShutdownScript script); +void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Checks if two APIErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. */ -bool APIError_eq(const struct LDKAPIError *NONNULL_PTR a, const struct LDKAPIError *NONNULL_PTR b); +struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Serialize the APIError object into a byte array which can be read by APIError_read + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. */ -struct LDKCVec_u8Z APIError_write(const struct LDKAPIError *NONNULL_PTR obj); +void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Read a APIError from a byte array, created by APIError_write + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. */ -struct LDKCResult_COption_APIErrorZDecodeErrorZ APIError_read(struct LDKu8slice ser); +struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BigSize, if is_owned is set and inner is non-NULL. + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. */ -void BigSize_free(struct LDKBigSize this_obj); - -uint64_t BigSize_get_a(const struct LDKBigSize *NONNULL_PTR this_ptr); - -void BigSize_set_a(struct LDKBigSize *NONNULL_PTR this_ptr, uint64_t val); +void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); /** - * Constructs a new BigSize given each field + * True if the channel was initiated (and thus funded) by us. */ -MUST_USE_RES struct LDKBigSize BigSize_new(uint64_t a_arg); +bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Hostname, if is_owned is set and inner is non-NULL. + * True if the channel was initiated (and thus funded) by us. */ -void Hostname_free(struct LDKHostname this_obj); +void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Creates a copy of the Hostname + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required */ -struct LDKHostname Hostname_clone(const struct LDKHostname *NONNULL_PTR orig); +bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Checks if two Hostnames 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. + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required */ -bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostname *NONNULL_PTR b); +void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Returns the length of the hostname. + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * + * Returns a copy of the field. */ -MUST_USE_RES uint8_t Hostname_len(const struct LDKHostname *NONNULL_PTR this_arg); +struct LDKCOption_ChannelShutdownStateZ ChannelDetails_get_channel_shutdown_state(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Creates a digital signature of a message given a SecretKey, like the node's secret. - * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. - * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. */ -struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); +void ChannelDetails_set_channel_shutdown_state(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_ChannelShutdownStateZ val); /** - * Recovers the PublicKey of the signer of the message given the message and the signature. + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. */ -struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); +bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Verifies a message was signed by a PrivateKey that derives to a given PublicKey, given a message, a signature, - * and the PublicKey. + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. */ -bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); +void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Construct the invoice's HRP and signatureless data into a preimage to be hashed. + * True if this channel is (or will be) publicly-announced. */ -struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z data_without_signature); +bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * True if this channel is (or will be) publicly-announced. */ -void Persister_free(struct LDKPersister this_ptr); +void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 */ -void UntrustedString_free(struct LDKUntrustedString this_obj); - -struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); - -void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Constructs a new UntrustedString given each field + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 */ -MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); +void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Creates a copy of the UntrustedString + * The largest value HTLC (in msat) we currently will accept, for this channel. */ -struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Checks if two UntrustedStrings 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. + * The largest value HTLC (in msat) we currently will accept, for this channel. */ -bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); +void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); +struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** - * Read a UntrustedString from a byte array, created by UntrustedString_write + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); +void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. + * Constructs a new ChannelDetails given each field */ -void PrintableString_free(struct LDKPrintableString this_obj); - -struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); - -void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t next_outbound_htlc_minimum_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, struct LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); /** - * Constructs a new PrintableString given each field + * Creates a copy of the ChannelDetails */ -MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Gets the current SCID which should be used to identify this channel for inbound payments. + * This should be used for providing invoice hints or in any other context where our + * counterparty will forward a payment to us. + * + * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the + * [`ChannelDetails::short_channel_id`]. See those for more information. */ -void FutureCallback_free(struct LDKFutureCallback this_ptr); +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); /** - * Frees any resources used by the Future, if is_owned is set and inner is non-NULL. + * Gets the current SCID which should be used to identify this channel for outbound payments. + * This should be used in [`Route`]s to describe the first hop or in other contexts where + * we're sending or forwarding a payment outbound over this channel. + * + * This is either the [`ChannelDetails::short_channel_id`], if set, or the + * [`ChannelDetails::outbound_scid_alias`]. See those for more information. */ -void Future_free(struct LDKFuture this_obj); +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); /** - * Creates a copy of the Future + * Creates a copy of the ChannelShutdownState */ -struct LDKFuture Future_clone(const struct LDKFuture *NONNULL_PTR orig); +enum LDKChannelShutdownState ChannelShutdownState_clone(const enum LDKChannelShutdownState *NONNULL_PTR orig); /** - * Registers a callback to be called upon completion of this future. If the future has already - * completed, the callback will be called immediately. + * Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState */ -void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback); +enum LDKChannelShutdownState ChannelShutdownState_not_shutting_down(void); /** - * Waits until this [`Future`] completes. + * Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState */ -void Future_wait(struct LDKFuture this_arg); +enum LDKChannelShutdownState ChannelShutdownState_shutdown_initiated(void); /** - * Waits until this [`Future`] completes or the given amount of time has elapsed. - * - * Returns true if the [`Future`] completed, false if the time elapsed. + * Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState */ -MUST_USE_RES bool Future_wait_timeout(struct LDKFuture this_arg, uint64_t max_wait); +enum LDKChannelShutdownState ChannelShutdownState_resolving_htlcs(void); /** - * Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState */ -void Sleeper_free(struct LDKSleeper this_obj); +enum LDKChannelShutdownState ChannelShutdownState_negotiating_closing_fee(void); /** - * Constructs a new sleeper from one future, allowing blocking on it. + * Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState */ -MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(struct LDKFuture future); +enum LDKChannelShutdownState ChannelShutdownState_shutdown_complete(void); /** - * Constructs a new sleeper from two futures, allowing blocking on both at once. + * Checks if two ChannelShutdownStates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(struct LDKFuture fut_a, struct LDKFuture fut_b); +bool ChannelShutdownState_eq(const enum LDKChannelShutdownState *NONNULL_PTR a, const enum LDKChannelShutdownState *NONNULL_PTR b); /** - * Constructs a new sleeper on many futures, allowing blocking on all at once. + * Frees any resources used by the RecentPaymentDetails */ -MUST_USE_RES struct LDKSleeper Sleeper_new(struct LDKCVec_FutureZ futures); +void RecentPaymentDetails_free(struct LDKRecentPaymentDetails this_ptr); /** - * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed. + * Creates a copy of the RecentPaymentDetails */ -void Sleeper_wait(const struct LDKSleeper *NONNULL_PTR this_arg); +struct LDKRecentPaymentDetails RecentPaymentDetails_clone(const struct LDKRecentPaymentDetails *NONNULL_PTR orig); /** - * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the - * given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time - * elapsed. + * Utility method to constructs a new Pending-variant RecentPaymentDetails */ -MUST_USE_RES bool Sleeper_wait_timeout(const struct LDKSleeper *NONNULL_PTR this_arg, uint64_t max_wait); +struct LDKRecentPaymentDetails RecentPaymentDetails_pending(struct LDKThirtyTwoBytes payment_hash, uint64_t total_msat); /** - * Creates a copy of the Level + * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails */ -enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); +struct LDKRecentPaymentDetails RecentPaymentDetails_fulfilled(struct LDKCOption_PaymentHashZ payment_hash); /** - * Utility method to constructs a new Gossip-variant Level + * Utility method to constructs a new Abandoned-variant RecentPaymentDetails */ -enum LDKLevel Level_gossip(void); +struct LDKRecentPaymentDetails RecentPaymentDetails_abandoned(struct LDKThirtyTwoBytes payment_hash); /** - * Utility method to constructs a new Trace-variant Level + * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. */ -enum LDKLevel Level_trace(void); +void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); /** - * Utility method to constructs a new Debug-variant Level + * The list of channels to be included in the invoice route hints. */ -enum LDKLevel Level_debug(void); +struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Info-variant Level + * The list of channels to be included in the invoice route hints. */ -enum LDKLevel Level_info(void); +void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); /** - * Utility method to constructs a new Warn-variant Level + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -enum LDKLevel Level_warn(void); +uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Error-variant Level + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -enum LDKLevel Level_error(void); +void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two Levels contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The pubkey of the real backing node that would ultimately receive the payment. */ -bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); +struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Level. + * The pubkey of the real backing node that would ultimately receive the payment. */ -uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); +void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Returns the most verbose logging level. + * Constructs a new PhantomRouteHints given each field */ -MUST_USE_RES enum LDKLevel Level_max(void); +MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); /** - * Frees any resources used by the Record, if is_owned is set and inner is non-NULL. + * Creates a copy of the PhantomRouteHints */ -void Record_free(struct LDKRecord this_obj); +struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); /** - * The verbosity level of the message. + * Constructs a new `ChannelManager` to hold several channels and route between them. + * + * The current time or latest block header time can be provided as the `current_timestamp`. + * + * This is the main \"logic hub\" for all channel-related actions, and implements + * [`ChannelMessageHandler`]. + * + * Non-proportional fees are fixed according to our risk using the provided fee estimator. + * + * Users need to notify the new `ChannelManager` when a new block is connected or + * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting + * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for + * more details. + * + * [`block_connected`]: chain::Listen::block_connected + * [`block_disconnected`]: chain::Listen::block_disconnected + * [`params.best_block.block_hash`]: chain::BestBlock::block_hash */ -enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKUserConfig config, struct LDKChainParameters params, uint32_t current_timestamp); /** - * The verbosity level of the message. + * Gets the current configuration applied to all new channels. */ -void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val); +MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The message body. + * Creates a new outbound channel to the given remote node and with the given value. + * + * `user_channel_id` will be provided back as in + * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events + * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a + * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it + * is simply copied to events and otherwise ignored. + * + * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is + * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`]. + * + * Note that we do not check if you are currently connected to the given peer. If no + * connection is available, the outbound `open_channel` message may fail to send, resulting in + * the channel eventually being silently forgotten (dropped on reload). + * + * Returns the new Channel's temporary `channel_id`. This ID will appear as + * [`Event::FundingGenerationReady::temporary_channel_id`] and in + * [`ChannelDetails::channel_id`] until after + * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for + * one derived from the funding transaction's TXID. If the counterparty rejects the channel + * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. + * + * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id + * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id + * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id + * + * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult__u832APIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, struct LDKU128 user_channel_id, struct LDKUserConfig override_config); /** - * The message body. + * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for + * more information. */ -void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The module path of the message. + * Gets the list of usable channels, in random order. Useful as an argument to + * [`Router::find_route`] to ensure non-announced channels are used. + * + * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the + * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria + * are. */ -struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The module path of the message. + * Gets the list of channels we have with a given counterparty, in random order. */ -void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels_with_counterparty(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); /** - * The source file containing the message. + * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a + * successful path, or have unresolved HTLCs. + * + * This can be useful for payments that may have been prepared, but ultimately not sent, as a + * result of a crash. If such a payment exists, is not listed here, and an + * [`Event::PaymentSent`] has not been received, you may consider resending the payment. + * + * [`Event::PaymentSent`]: events::Event::PaymentSent */ -struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_RecentPaymentDetailsZ ChannelManager_list_recent_payments(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The source file containing the message. + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * * If we are the channel initiator, we will pay between our [`Background`] and + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee + * estimate. + * * If our counterparty is the channel initiator, we will require a channel closing + * transaction feerate of at least our [`Background`] feerate or the feerate which + * would appear on a force-closure transaction, whichever is lower. We will allow our + * counterparty to pay as much fee as they'd like, however. + * + * May generate a [`SendShutdown`] message event on success, which should be relayed. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the + * channel. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown */ -void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * The line containing the message. + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated + * the channel being closed or not: + * * If we are the channel initiator, we will pay at least this feerate on the closing + * transaction. The upper-bound is set by + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee + * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). + * * If our counterparty is the channel initiator, we will refuse to accept a channel closure + * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which + * will appear on a force-closure transaction, whichever is lower). + * + * The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction. + * Will fail if a shutdown script has already been set for this channel by + * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must + * also be compatible with our and the counterparty's features. + * + * May generate a [`SendShutdown`] message event on success, which should be relayed. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the + * channel. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * + * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_feerate_and_script(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKCOption_u32Z target_feerate_sats_per_1000_weight, struct LDKShutdownScript shutdown_script); /** - * The line containing the message. + * Force closes a channel, immediately broadcasting the latest local transaction(s) and + * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to + * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding + * channel. */ -void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * Creates a copy of the Record + * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting + * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the + * `counterparty_node_id` isn't the counterparty of the corresponding channel. + * + * You can always get the latest local transaction(s) to broadcast from + * [`ChannelMonitor::get_latest_holder_commitment_txn`]. */ -struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); /** - * Calls the free function if one is set + * Force close all channels, immediately broadcasting the latest local commitment transaction + * for each to the chain and rejecting new HTLCs on each. */ -void Logger_free(struct LDKLogger this_ptr); +void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL. + * Force close all channels rejecting new HTLCs on each but without broadcasting the latest + * local transaction(s). */ -void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); +void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). + * Sends a payment along a given route. * - * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment - * transaction before operation. If you wish to accept channels with zero confirmations, see - * [`UserConfig::manually_accept_inbound_channels`] and - * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] + * fields for more info. * - * Default value: 6. + * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via + * [`PeerManager::process_events`]). * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf - */ -uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); - -/** - * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the - * equivalent limit applied to outbound channels). + * # Avoiding Duplicate Payments * - * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment - * transaction before operation. If you wish to accept channels with zero confirmations, see - * [`UserConfig::manually_accept_inbound_channels`] and - * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this + * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment + * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an + * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a + * second payment with the same [`PaymentId`]. * - * Default value: 6. + * Thus, in order to ensure duplicate payments are not sent, you should implement your own + * tracking of payments, including state to indicate once a payment has completed. Because you + * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should + * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the + * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes. * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf + * Additionally, in the scenario where we begin the process of sending a payment, but crash + * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're + * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See + * [`ChannelManager::list_recent_payments`] for more information. + * + * # Possible Error States on [`PaymentSendFailure`] + * + * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with + * each entry matching the corresponding-index entry in the route paths, see + * [`PaymentSendFailure`] for more info. + * + * In general, a path may raise: + * * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee, + * node public key) is specified. + * * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates + * (including due to previous monitor update failure or new permanent monitor update + * failure). + * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the + * relevant updates. + * + * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been + * irrevocably committed to on our end. In such a case, do NOT retry the payment with a + * different route unless you intend to pay twice! + * + * [`RouteHop`]: crate::routing::router::RouteHop + * [`Event::PaymentSent`]: events::Event::PaymentSent + * [`Event::PaymentFailed`]: events::Event::PaymentFailed + * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ -void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). + * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on + * `route_params` and retry failed payment paths based on `retry_strategy`. + */ +MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); + +/** + * Signals that no further retries for the given payment should occur. Useful if you have a + * pending outbound payment with retries remaining, but wish to stop retrying the payment before + * retries are exhausted. * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). + * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon + * as there are no remaining pending HTLCs for this payment. * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. + * Note that calling this method does *not* prevent a payment from succeeding. You must still + * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to + * determine the ultimate status of a payment. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * If an [`Event::PaymentFailed`] event is generated and we restart without this + * [`ChannelManager`] having been persisted, another [`Event::PaymentFailed`] may be generated. + * + * [`Event::PaymentFailed`]: events::Event::PaymentFailed + * [`Event::PaymentSent`]: events::Event::PaymentSent */ -uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); /** - * Set to the number of blocks we require our counterparty to wait to claim their money (ie - * the number of blocks we have to punish our counterparty if they broadcast a revoked - * transaction). + * Send a spontaneous payment, which is a payment that does not require the recipient to have + * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify + * the preimage, it must be a cryptographically secure random value that no intermediate node + * would be able to guess -- otherwise, an intermediate node may claim the payment and it will + * never reach the recipient. * - * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST - * be online to check for revoked transactions on-chain at least once every our_to_self_delay - * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, - * possibly with time in between to RBF the spending transaction). + * See [`send_payment`] documentation for more details on the return value of this function + * and idempotency guarantees provided by the [`PaymentId`] key. * - * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in - * case of an honest unilateral channel close, which implicitly decrease the economic value of - * our channel. + * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See + * [`send_payment`] for more information about the risks of duplicate preimage usage. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * [`send_payment`]: Self::send_payment */ -void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKCOption_PaymentPreimageZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** - * Set to the smallest value HTLC we will accept to process. + * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route + * based on `route_params` and retry failed payment paths based on `retry_strategy`. * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous + * payments. * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend */ -uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_PaymentHashRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_PaymentPreimageZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /** - * Set to the smallest value HTLC we will accept to process. - * - * This value is sent to our counterparty on channel-open and we close the channel any time - * our counterparty misbehaves by sending us an HTLC with a value smaller than this. - * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Send a payment that is probing the given route for liquidity. We calculate the + * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows + * us to easily discern them from real payments. */ -void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPath path); /** - * Sets the percentage of the channel value we will cap the total value of outstanding inbound - * HTLCs to. + * Call this upon creation of a funding transaction for the given channel. * - * This can be set to a value between 1-100, where the value corresponds to the percent of the - * channel value in whole percentages. + * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs + * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. * - * Note that: - * * If configured to another value than the default value 10, any new channels created with - * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the - * `ChannelManager`. + * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation + * across the p2p network. * - * * This caps the total value for inbound HTLCs in-flight only, and there's currently - * no way to configure the cap for the total value of outbound HTLCs in-flight. + * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided + * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. * - * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds - * are different from the non-HTLC-encumbered funds. This makes this an important knob to - * restrict exposure to loss due to being offline for too long. - * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] - * for more information. + * May panic if the output found in the funding transaction is duplicative with some other + * channel (note that this should be trivially prevented by using unique funding transaction + * keys per-channel). * - * Default value: 10. - * Minimum value: 1, any values less than 1 will be treated as 1 instead. - * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + * Do NOT broadcast the funding transaction yourself. When we have safely received our + * counterparty's signature the funding transaction will automatically be broadcast via the + * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. + * + * Note that this includes RBF or similar transaction replacement strategies - lightning does + * not currently support replacing a funding transaction on an existing channel. Instead, + * create a new channel with a conflicting funding transaction. + * + * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend + * the wallet software generating the funding transaction to apply anti-fee sniping as + * implemented by Bitcoin Core wallet. See + * for more details. + * + * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady + * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed */ -uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +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 LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); /** - * Sets the percentage of the channel value we will cap the total value of outstanding inbound - * HTLCs to. + * Atomically applies partial updates to the [`ChannelConfig`] of the given channels. * - * This can be set to a value between 1-100, where the value corresponds to the percent of the - * channel value in whole percentages. + * Once the updates are applied, each eligible channel (advertised with a known short channel + * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], + * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated + * containing the new [`ChannelUpdate`] message which should be broadcast to the network. * - * Note that: - * * If configured to another value than the default value 10, any new channels created with - * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the - * `ChannelManager`. + * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect + * `counterparty_node_id` is provided. * - * * This caps the total value for inbound HTLCs in-flight only, and there's currently - * no way to configure the cap for the total value of outbound HTLCs in-flight. + * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value + * below [`MIN_CLTV_EXPIRY_DELTA`]. * - * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds - * are different from the non-HTLC-encumbered funds. This makes this an important knob to - * restrict exposure to loss due to being offline for too long. - * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] - * for more information. + * If an error is returned, none of the updates should be considered applied. * - * Default value: 10. - * Minimum value: 1, any values less than 1 will be treated as 1 instead. - * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat + * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta + * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelUnavailable`]: APIError::ChannelUnavailable + * [`APIMisuseError`]: APIError::APIMisuseError */ -void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_partial_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfigUpdate *NONNULL_PTR config_update); /** - * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the - * BOLTs) option for outbound private channels. This provides better privacy by not including - * our real on-chain channel UTXO in each invoice and requiring that our counterparty only - * relay HTLCs to us using the channel's SCID alias. + * Atomically updates the [`ChannelConfig`] for the given channels. * - * If this option is set, channels may be created that will not be readable by LDK versions - * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a - * [`DecodeError::InvalidValue`]. + * Once the updates are applied, each eligible channel (advertised with a known short channel + * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], + * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated + * containing the new [`ChannelUpdate`] message which should be broadcast to the network. * - * Note that setting this to true does *not* prevent us from opening channels with - * counterparties that do not support the `scid_alias` option; we will simply fall back to a - * private channel without that option. + * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect + * `counterparty_node_id` is provided. * - * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value + * below [`MIN_CLTV_EXPIRY_DELTA`]. * - * Default value: false. This value is likely to change to true in the future. + * If an error is returned, none of the updates should be considered applied. * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat + * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta + * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelUnavailable`]: APIError::ChannelUnavailable + * [`APIMisuseError`]: APIError::APIMisuseError */ -bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfig *NONNULL_PTR config); /** - * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the - * BOLTs) option for outbound private channels. This provides better privacy by not including - * our real on-chain channel UTXO in each invoice and requiring that our counterparty only - * relay HTLCs to us using the channel's SCID alias. + * Attempts to forward an intercepted HTLC over the provided channel id and with the provided + * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event. * - * If this option is set, channels may be created that will not be readable by LDK versions - * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a - * [`DecodeError::InvalidValue`]. + * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time + * channel to a receiving node if the node lacks sufficient inbound liquidity. * - * Note that setting this to true does *not* prevent us from opening channels with - * counterparties that do not support the `scid_alias` option; we will simply fall back to a - * private channel without that option. + * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use + * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the + * receiver's invoice route hints. These route hints will signal to LDK to generate an + * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or + * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. * - * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop + * you from forwarding more than you received. See + * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount + * than expected. * - * Default value: false. This value is likely to change to true in the future. + * Errors if the event was not handled in time, in which case the HTLC was automatically failed + * backwards. * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs + * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat */ -void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_forward_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id, const uint8_t (*next_hop_channel_id)[32], struct LDKPublicKey next_node_id, uint64_t amt_to_forward_msat); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. + * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to + * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`]. * - * This should only be set to true for nodes which expect to be online reliably. + * Errors if the event was not handled in time, in which case the HTLC was automatically failed + * backwards. * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + */ +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_fail_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id); + +/** + * Processes HTLCs which are pending waiting on random forward delay. * - * Default value: false. + * Should only really ever be called in response to a PendingHTLCsForwardable event. + * Will likely generate further events. */ -bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Set to announce the channel publicly and notify all nodes that they can route via this - * channel. + * Performs actions which should happen on startup and roughly once per minute thereafter. * - * This should only be set to true for nodes which expect to be online reliably. + * This currently includes: + * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, + * * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more + * than a minute, informing the network that they should no longer attempt to route over + * the channel. + * * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs + * with the current [`ChannelConfig`]. + * * Removing peers which have disconnected but and no longer have any channels. + * * Force-closing and removing channels which have not completed establishment in a timely manner. * - * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate + * estimate fetches. * - * Default value: false. + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelConfig`]: crate::util::config::ChannelConfig */ -void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. - * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. - * - * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect + * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources + * along the path (including in our own channel on which we received it). * - * Default value: true. + * Note that in some cases around unclean shutdown, it is possible the payment may have + * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a + * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment + * may have already been failed automatically by LDK if it was nearing its expiration time. * - * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + * While LDK will never claim a payment automatically on your behalf (i.e. without you calling + * [`ChannelManager::claim_funds`]), you should still monitor for + * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on + * startup during which time claims that were in-progress at shutdown may be replayed. */ -bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +void ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); /** - * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty - * supports it, they will then enforce the mutual-close output to us matches what we provided - * at intialization, preventing us from closing to an alternate pubkey. + * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the + * reason for the failure. * - * This is set to true by default to provide a slight increase in security, though ultimately - * any attacker who is able to take control of a channel can just as easily send the funds via - * lightning payments, so we never require that our counterparties support this option. + * See [`FailureCode`] for valid failure codes. + */ +void ChannelManager_fail_htlc_backwards_with_reason(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32], enum LDKFailureCode failure_code); + +/** + * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any + * [`MessageSendEvent`]s needed to claim the payment. * - * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * This method is guaranteed to ensure the payment has been claimed but only if the current + * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race + * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment + * successful. It will generally be available in the next [`process_pending_events`] call. * - * Default value: true. + * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or + * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` + * event matches your expectation. If you fail to do so and call this method, you may provide + * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. * - * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable + * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline + * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed + * [`process_pending_events`]: EventsProvider::process_pending_events + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +void ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); /** - * The Proportion of the channel value to configure as counterparty's channel reserve, - * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * Gets the node_id held by this ChannelManager + */ +MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Accepts a request to open a channel after a [`Event::OpenChannelRequest`]. * - * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain - * on their side, at all times. - * This ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. + * The `temporary_channel_id` parameter indicates which inbound channel should be accepted, + * and the `counterparty_node_id` parameter is the id of the peer which has requested to open + * the channel. * - * Channel reserve values greater than 30% could be considered highly unreasonable, since that - * amount can never be used for payments. - * Also, if our selected channel reserve for counterparty and counterparty's selected - * channel reserve for us sum up to equal or greater than channel value, channel negotiations - * will fail. + * The `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. * - * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve - * other than the default value. + * Note that this method will return an error and reject the channel, if it requires support + * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be + * used to accept such channels. * - * Default value: 1% of channel value, i.e., configured as 10,000 millionths. - * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated - * as 1000 sats instead, which is a safe implementation-specific lower bound. - * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) - * instead, although channel negotiations will fail in that case. + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); /** - * The Proportion of the channel value to configure as counterparty's channel reserve, - * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating + * it as confirmed immediately. * - * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain - * on their side, at all times. - * This ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. + * The `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. * - * Channel reserve values greater than 30% could be considered highly unreasonable, since that - * amount can never be used for payments. - * Also, if our selected channel reserve for counterparty and counterparty's selected - * channel reserve for us sum up to equal or greater than channel value, channel negotiations - * will fail. + * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel + * and (if the counterparty agrees), enables forwarding of payments immediately. * - * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve - * other than the default value. + * This fully trusts that the counterparty has honestly and correctly constructed the funding + * transaction and blindly assumes that it will eventually confirm. * - * Default value: 1% of channel value, i.e., configured as 10,000 millionths. - * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated - * as 1000 sats instead, which is a safe implementation-specific lower bound. - * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) - * instead, although channel negotiations will fail in that case. + * If it does not confirm before we decide to close the channel, or if the funding transaction + * does not pay to the correct script the correct amount, *you will lose funds*. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); /** - * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * Gets a payment secret and payment hash for use in an invoice given to a third party wishing + * to pay us. * - * Increasing the value can help improve liquidity and stability in - * routing at the cost of higher long term disk / DB usage. + * This differs from [`create_inbound_payment_for_hash`] only in that it generates the + * [`PaymentHash`] and [`PaymentPreimage`] for you. * - * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration - * other than the default value. + * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which + * will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with + * its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be + * passed directly to [`claim_funds`]. * - * Default value: 50 - * Maximum value: 483, any values larger will be treated as 483. - * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. + * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * + * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [`claim_funds`]: Self::claim_funds + * [`PaymentClaimable`]: events::Event::PaymentClaimable + * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose + * [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment + * [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is + * stored external to LDK. * - * Increasing the value can help improve liquidity and stability in - * routing at the cost of higher long term disk / DB usage. + * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a + * payment secret fetched via this method or [`create_inbound_payment`], and which is at least + * the `min_value_msat` provided here, if one is provided. * - * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration - * other than the default value. + * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though + * note that LDK will not stop you from registering duplicate payment hashes for inbound + * payments. * - * Default value: 50 - * Maximum value: 483, any values larger will be treated as 483. - * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + * `min_value_msat` should be set if the invoice being generated contains a value. Any payment + * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` + * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the + * sender \"proof-of-payment\" unless they have paid the required amount. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. This should roughly match the expiry time set in the invoice. + * After this many seconds, we will remove the inbound payment, resulting in any attempts to + * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for + * invoices when no timeout is set. + * + * Note that we use block header time to time-out pending inbound payments (with some margin + * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will + * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. + * If you need exact expiry semantics, you should enforce them upon receipt of + * [`PaymentClaimable`]. + * + * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` + * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * + * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`PaymentClaimable`]: events::Event::PaymentClaimable */ -void ChannelHandshakeConfig_set_our_max_accepted_htlcs(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCResult_PaymentSecretNoneZ 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, struct LDKCOption_u16Z min_final_cltv_expiry); /** - * Constructs a new ChannelHandshakeConfig given each field + * Gets an LDK-generated payment preimage from a payment hash and payment secret that were + * previously returned from [`create_inbound_payment`]. + * + * [`create_inbound_payment`]: Self::create_inbound_payment */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg, uint16_t our_max_accepted_htlcs_arg); +MUST_USE_RES struct LDKCResult_PaymentPreimageAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); /** - * Creates a copy of the ChannelHandshakeConfig + * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids + * are used when constructing the phantom invoice's route hints. + * + * [phantom node payments]: crate::sign::PhantomKeysManager */ -struct LDKChannelHandshakeConfig ChannelHandshakeConfig_clone(const struct LDKChannelHandshakeConfig *NONNULL_PTR orig); +MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. + * Gets route hints for use in receiving [phantom node payments]. + * + * [phantom node payments]: crate::sign::PhantomKeysManager */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_default(void); +MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL. + * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are + * used when constructing the route hints for HTLCs intended to be intercepted. See + * [`ChannelManager::forward_intercepted_htlc`]. + * + * Note that this method is not guaranteed to return unique values, you may need to call it a few + * times to get a unique scid. */ -void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); +MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 0. + * Gets inflight HTLC information by processing pending outbound payments that are in + * our channels. May be used during pathfinding to account for in-use channel liquidity. */ -uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 0. + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 2^24 - 1. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so - * only applies to inbound channels. - * - * Default value: 2^24 - 1. + * 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 */ -void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. - * - * Default value: u64::max_value. + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is */ -uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows - * you to limit the maximum minimum-size they can require. + * Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChannelManager`] and should instead register actions to be taken later. * - * Default value: u64::max_value. */ -void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. - * - * Default value: 0. + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. */ -uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); -/** - * The remote node sets a limit on the maximum value of pending HTLCs to them at any given - * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. - * - * Default value: 0. +/** + * Fetches the set of [`NodeFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node will require we keep a certain amount in direct payment to ourselves at all - * time, ensuring that we are able to be punished if we broadcast an old state. This allows to - * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). - * - * Default value: u64::max_value. + * Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Fetches the set of [`InitFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The remote node sets a limit on the maximum number of pending HTLCs to them at any given - * time. This allows you to set a minimum such value. - * - * Default value: 0. + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. - * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Fetches the set of [`InitFeatures`] flags which are provided by or required by + * [`ChannelManager`]. */ -uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR config); /** - * Before a channel is usable the funding transaction will need to be confirmed by at least a - * certain number of blocks, specified by the node which is not the funder (as the funder can - * assume they aren't going to double-spend themselves). - * This config allows you to set a limit on the maximum amount of time to wait. - * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read */ -void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); /** - * Whether we implicitly trust funding transactions generated by us for our own outbound - * channels to not be double-spent. - * - * If this is set, we assume that our own funding transactions are *never* double-spent, and - * thus we can trust them without any confirmations. This is generally a reasonable - * assumption, given we're the only ones who could ever double-spend it (assuming we have sole - * control of the signing keys). - * - * You may wish to un-set this if you allow the user to (or do in an automated fashion) - * double-spend the funding transaction to RBF with an alternative channel open. - * - * This only applies if our counterparty set their confirmations-required value to 0, and we - * always trust our own funding transaction at 1 confirmation irrespective of this value. - * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being - * `true` (0) and `false` (1). - * - * Default value: true + * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write */ -bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); /** - * Whether we implicitly trust funding transactions generated by us for our own outbound - * channels to not be double-spent. - * - * If this is set, we assume that our own funding transactions are *never* double-spent, and - * thus we can trust them without any confirmations. This is generally a reasonable - * assumption, given we're the only ones who could ever double-spend it (assuming we have sole - * control of the signing keys). - * - * You may wish to un-set this if you allow the user to (or do in an automated fashion) - * double-spend the funding transaction to RBF with an alternative channel open. - * - * This only applies if our counterparty set their confirmations-required value to 0, and we - * always trust our own funding transaction at 1 confirmation irrespective of this value. - * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being - * `true` (0) and `false` (1). - * - * Default value: true + * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read */ -void ChannelHandshakeLimits_set_trust_own_funding_0conf(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); /** - * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. - * - * For a node which is not online reliably, this should be set to true and - * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) - * channels will ever be opened. - * - * Default value: true. + * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write */ -bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); /** - * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. - * - * For a node which is not online reliably, this should be set to true and - * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) - * channels will ever be opened. - * - * Default value: true. + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read */ -void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Read a ChannelDetails from a byte array, created by ChannelDetails_write */ -uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); /** - * Set to the amount of time we're willing to wait to claim money back to us. - * - * Not checking this value would be a security issue, as our peer would be able to set it to - * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. - * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to - * reduce the loss of having useless locked funds (if your peer accepts) + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read */ -void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); /** - * Constructs a new ChannelHandshakeLimits given each field + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_new(uint64_t min_funding_satoshis_arg, uint64_t max_funding_satoshis_arg, uint64_t max_htlc_minimum_msat_arg, uint64_t min_max_htlc_value_in_flight_msat_arg, uint64_t max_channel_reserve_satoshis_arg, uint16_t min_max_accepted_htlcs_arg, uint32_t max_minimum_depth_arg, bool trust_own_funding_0conf_arg, bool force_announced_channel_preference_arg, uint16_t their_to_self_delay_arg); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelHandshakeLimits + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read */ -struct LDKChannelHandshakeLimits ChannelHandshakeLimits_clone(const struct LDKChannelHandshakeLimits *NONNULL_PTR orig); +struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); /** - * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. + * Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read */ -MUST_USE_RES struct LDKChannelHandshakeLimits ChannelHandshakeLimits_default(void); +struct LDKCVec_u8Z ChannelShutdownState_write(const enum LDKChannelShutdownState *NONNULL_PTR obj); /** - * Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL. + * Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write */ -void ChannelConfig_free(struct LDKChannelConfig this_obj); +struct LDKCResult_ChannelShutdownStateDecodeErrorZ ChannelShutdownState_read(struct LDKu8slice ser); /** - * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - * over the channel. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. */ -uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); /** - * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - * over the channel. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * Default value: 0. + * A cryptographically secure source of entropy. */ -void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in - * excess of [`forwarding_fee_proportional_millionths`]. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * The default value of a single satoshi roughly matches the market rate on many routing nodes - * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through - * this node. - * - * Default value: 1000. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * A cryptographically secure source of entropy. */ -uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); /** - * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in - * excess of [`forwarding_fee_proportional_millionths`]. - * This may be allowed to change at runtime in a later update, however doing so must result in - * update messages sent to notify all nodes of our updated relay fee. - * - * The default value of a single satoshi roughly matches the market rate on many routing nodes - * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through - * this node. - * - * Default value: 1000. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * A signer that is able to perform node-scoped cryptographic operations. */ -void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); +const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * A signer that is able to perform node-scoped cryptographic operations. */ -uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); /** - * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over - * the channel this config applies to. - * - * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight - * HTLC balance when a channel appears on-chain whereas - * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining - * (non-HTLC-encumbered) balance. - * - * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed, - * we (or one of our watchtowers) MUST be online to check for broadcast of the current - * commitment transaction at least once per this many blocks (minus some margin to allow us - * enough time to broadcast and confirm a transaction, possibly with time in between to RBF - * the spending transaction). - * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. - * - * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); +const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. - * - * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will - * not be claimable on-chain, instead being turned into additional miner fees if either - * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the - * channel is force-closed. - * - * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a - * channel negotiated throughout the channel open process, along with the fees required to have - * a broadcastable HTLC spending transaction. When a channel supports anchor outputs - * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into - * account the HTLC transaction fee as it is zero. - * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. - * - * Default value: 5_000_000 msat. + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -uint64_t ChannelConfig_get_max_dust_htlc_exposure_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. - * - * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will - * not be claimable on-chain, instead being turned into additional miner fees if either - * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the - * channel is force-closed. - * - * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a - * channel negotiated throughout the channel open process, along with the fees required to have - * a broadcastable HTLC spending transaction. When a channel supports anchor outputs - * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into - * account the HTLC transaction fee as it is zero. - * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. + * The fee_estimator for use in the ChannelManager in the future. * - * Default value: 5_000_000 msat. + * No calls to the FeeEstimator will be made during deserialization. */ -void ChannelConfig_set_max_dust_htlc_exposure_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * The additional fee we're willing to pay to avoid waiting for the counterparty's - * `to_self_delay` to reclaim funds. - * - * When we close a channel cooperatively with our counterparty, we negotiate a fee for the - * closing transaction which both sides find acceptable, ultimately paid by the channel - * funder/initiator. - * - * When we are the funder, because we have to pay the channel closing fee, we bound the - * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by - * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our - * [`Normal`] feerate during normal operation, this value represents the additional fee we're - * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our - * funds. - * - * When we are not the funder, we require the closing transaction fee pay at least our - * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. - * Thus, this value is ignored when we are not the funder. - * - * Default value: 1000 satoshis. + * The fee_estimator for use in the ChannelManager in the future. * - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * No calls to the FeeEstimator will be made during deserialization. */ -uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct LDKChannelConfig *NONNULL_PTR this_ptr); +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); /** - * The additional fee we're willing to pay to avoid waiting for the counterparty's - * `to_self_delay` to reclaim funds. - * - * When we close a channel cooperatively with our counterparty, we negotiate a fee for the - * closing transaction which both sides find acceptable, ultimately paid by the channel - * funder/initiator. - * - * When we are the funder, because we have to pay the channel closing fee, we bound the - * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by - * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our - * [`Normal`] feerate during normal operation, this value represents the additional fee we're - * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our - * funds. - * - * When we are not the funder, we require the closing transaction fee pay at least our - * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like. - * Thus, this value is ignored when we are not the funder. - * - * Default value: 1000 satoshis. + * The chain::Watch for use in the ChannelManager in the future. * - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint64_t val); +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Constructs a new ChannelConfig given each field + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, uint64_t max_dust_htlc_exposure_msat_arg, uint64_t force_close_avoidance_max_fee_satoshis_arg); +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); /** - * Creates a copy of the ChannelConfig + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Checks if two ChannelConfigs 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. + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -bool ChannelConfig_eq(const struct LDKChannelConfig *NONNULL_PTR a, const struct LDKChannelConfig *NONNULL_PTR b); +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); /** - * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * + * No calls to the router will be made during deserialization. */ -MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); +const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * + * No calls to the router will be made during deserialization. */ -struct LDKCVec_u8Z ChannelConfig_write(const struct LDKChannelConfig *NONNULL_PTR obj); +void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); /** - * Read a ChannelConfig from a byte array, created by ChannelConfig_write + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -struct LDKCResult_ChannelConfigDecodeErrorZ ChannelConfig_read(struct LDKu8slice ser); +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. */ -void UserConfig_free(struct LDKUserConfig this_obj); +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); /** - * Channel handshake config that we propose to our counterparty. + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -struct LDKChannelHandshakeConfig UserConfig_get_channel_handshake_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Channel handshake config that we propose to our counterparty. + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. */ -void UserConfig_set_channel_handshake_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeConfig val); +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); /** - * Limits applied to our counterparty's proposed channel handshake config settings. + * Simple utility function to create a ChannelManagerReadArgs which creates the monitor + * HashMap for you. This is primarily useful for C bindings where it is not practical to + * populate a HashMap directly from C. */ -struct LDKChannelHandshakeLimits UserConfig_get_channel_handshake_limits(const struct LDKUserConfig *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); /** - * Limits applied to our counterparty's proposed channel handshake config settings. + * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write */ -void UserConfig_set_channel_handshake_limits(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelHandshakeLimits val); +struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); /** - * Channel config which affects behavior during channel lifetime. + * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. */ -struct LDKChannelConfig UserConfig_get_channel_config(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void ExpandedKey_free(struct LDKExpandedKey this_obj); /** - * Channel config which affects behavior during channel lifetime. + * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. + * + * It is recommended to cache this value and not regenerate it for each new inbound payment. */ -void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(const uint8_t (*key_material)[32]); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private - * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a - * node which is not online reliably. + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no + * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without + * a `ChannelManager`. * - * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to - * ensure you are not exposed to any forwarding risk. + * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then + * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not + * regenerate it for each new inbound payment. * - * Note that because you cannot change a channel's announced state after creation, there is no - * way to disable forwarding on public channels retroactively. Thus, in order to change a node - * from a publicly-announced forwarding node to a private non-forwarding node you must close - * all your channels and open new ones. For privacy, you should also change your node_id - * (swapping all private and public key material for new ones) at that time. + * `current_time` is a Unix timestamp representing the current time. * - * Default value: false. + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material */ -bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private - * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a - * node which is not online reliably. + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], + * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] + * without a `ChannelManager`. * - * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to - * ensure you are not exposed to any forwarding risk. + * See [`create`] for information on the `keys` and `current_time` parameters. * - * Note that because you cannot change a channel's announced state after creation, there is no - * way to disable forwarding on public channels retroactively. Thus, in order to change a node - * from a publicly-announced forwarding node to a private non-forwarding node you must close - * all your channels and open new ones. For privacy, you should also change your node_id - * (swapping all private and public key material for new ones) at that time. + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. * - * Default value: false. + * [phantom node payments]: crate::sign::PhantomKeysManager */ -void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKCResult_PaymentSecretNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * Frees any resources used by the DecodeError */ -bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +void DecodeError_free(struct LDKDecodeError this_ptr); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * Creates a copy of the DecodeError */ -void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new - * channel. - * - * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a - * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a - * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the - * user explicitly chooses to accept the request. - * - * Default value: false. - * - * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest - * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel - * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + * Utility method to constructs a new UnknownVersion-variant DecodeError */ -bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKDecodeError DecodeError_unknown_version(void); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new - * channel. - * - * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a - * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a - * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the - * user explicitly chooses to accept the request. - * - * Default value: false. - * - * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest - * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel - * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError */ -void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKDecodeError DecodeError_unknown_required_feature(void); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over - * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC - * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. - * - * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. - * - * Default value: false. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * Utility method to constructs a new InvalidValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_invalid_value(void); + +/** + * Utility method to constructs a new ShortRead-variant DecodeError */ -bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_PTR this_ptr); +struct LDKDecodeError DecodeError_short_read(void); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over - * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC - * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. - * - * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. - * - * Default value: false. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * Utility method to constructs a new BadLengthDescriptor-variant DecodeError */ -void UserConfig_set_accept_intercept_htlcs(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +struct LDKDecodeError DecodeError_bad_length_descriptor(void); /** - * Constructs a new UserConfig given each field + * Utility method to constructs a new Io-variant DecodeError */ -MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig channel_handshake_config_arg, struct LDKChannelHandshakeLimits channel_handshake_limits_arg, struct LDKChannelConfig channel_config_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg, bool accept_intercept_htlcs_arg); +struct LDKDecodeError DecodeError_io(enum LDKIOError a); /** - * Creates a copy of the UserConfig + * Utility method to constructs a new UnsupportedCompression-variant DecodeError */ -struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); +struct LDKDecodeError DecodeError_unsupported_compression(void); /** - * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. + * Checks if two DecodeErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKUserConfig UserConfig_default(void); +bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); /** - * Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. */ -void BestBlock_free(struct LDKBestBlock this_obj); +void Init_free(struct LDKInit this_obj); /** - * Creates a copy of the BestBlock + * The relevant features which the sender supports. */ -struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Checks if two BestBlocks 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. + * The relevant features which the sender supports. */ -bool BestBlock_eq(const struct LDKBestBlock *NONNULL_PTR a, const struct LDKBestBlock *NONNULL_PTR b); +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Constructs a `BestBlock` that represents the genesis block at height 0 of the given - * network. + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. + * + * Returns a copy of the field. */ -MUST_USE_RES struct LDKBestBlock BestBlock_from_network(enum LDKNetwork network); +struct LDKCOption_CVec_ChainHashZZ Init_get_networks(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Returns a `BestBlock` as identified by the given block hash and height. + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. */ -MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); +void Init_set_networks(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_CVec_ChainHashZZ val); /** - * Returns the best block hash. + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. */ -MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); +struct LDKCOption_NetAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); /** - * Returns the best block height. + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. */ -MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); +void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_NetAddressZ val); /** - * Calls the free function if one is set + * Constructs a new Init given each field */ -void Listen_free(struct LDKListen this_ptr); +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_CVec_ChainHashZZ networks_arg, struct LDKCOption_NetAddressZ remote_network_address_arg); /** - * Calls the free function if one is set + * Creates a copy of the Init */ -void Confirm_free(struct LDKConfirm this_ptr); +struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); /** - * Creates a copy of the ChannelMonitorUpdateStatus + * Checks if two Inits 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. */ -enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_clone(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR orig); +bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); /** - * Utility method to constructs a new Completed-variant ChannelMonitorUpdateStatus + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. */ -enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_completed(void); +void ErrorMessage_free(struct LDKErrorMessage this_obj); /** - * Utility method to constructs a new InProgress-variant ChannelMonitorUpdateStatus + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. */ -enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_in_progress(void); +const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateStatus + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. */ -enum LDKChannelMonitorUpdateStatus ChannelMonitorUpdateStatus_permanent_failure(void); +void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two ChannelMonitorUpdateStatuss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ -bool ChannelMonitorUpdateStatus_eq(const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR a, const enum LDKChannelMonitorUpdateStatus *NONNULL_PTR b); +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ -void Watch_free(struct LDKWatch this_ptr); +void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Calls the free function if one is set + * Constructs a new ErrorMessage given each field */ -void Filter_free(struct LDKFilter this_ptr); +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); /** - * Frees any resources used by the WatchedOutput, if is_owned is set and inner is non-NULL. + * Creates a copy of the ErrorMessage */ -void WatchedOutput_free(struct LDKWatchedOutput this_obj); +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); /** - * First block where the transaction output may have been spent. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two ErrorMessages 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. */ -struct LDKThirtyTwoBytes WatchedOutput_get_block_hash(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); /** - * First block where the transaction output may have been spent. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. */ -void WatchedOutput_set_block_hash(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void WarningMessage_free(struct LDKWarningMessage this_obj); /** - * Outpoint identifying the transaction output. + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. */ -struct LDKOutPoint WatchedOutput_get_outpoint(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; /** - * Outpoint identifying the transaction output. + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. */ -void WatchedOutput_set_outpoint(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Spending condition of the transaction output. + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ -struct LDKu8slice WatchedOutput_get_script_pubkey(const struct LDKWatchedOutput *NONNULL_PTR this_ptr); +struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); /** - * Spending condition of the transaction output. + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ -void WatchedOutput_set_script_pubkey(struct LDKWatchedOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Constructs a new WatchedOutput given each field + * Constructs a new WarningMessage given each field */ -MUST_USE_RES struct LDKWatchedOutput WatchedOutput_new(struct LDKThirtyTwoBytes block_hash_arg, struct LDKOutPoint outpoint_arg, struct LDKCVec_u8Z script_pubkey_arg); +MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); /** - * Creates a copy of the WatchedOutput + * Creates a copy of the WarningMessage */ -struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNULL_PTR orig); +struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); /** - * Checks if two WatchedOutputs contain equal inner contents. + * Checks if two WarningMessages 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. */ -bool WatchedOutput_eq(const struct LDKWatchedOutput *NONNULL_PTR a, const struct LDKWatchedOutput *NONNULL_PTR b); +bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the WatchedOutput. + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. */ -uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); +void Ping_free(struct LDKPing this_obj); /** - * Calls the free function if one is set + * The desired response length. */ -void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); +uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Creates a copy of the ConfirmationTarget + * The desired response length. */ -enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); +void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Utility method to constructs a new Background-variant ConfirmationTarget + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. */ -enum LDKConfirmationTarget ConfirmationTarget_background(void); +uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Normal-variant ConfirmationTarget + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. */ -enum LDKConfirmationTarget ConfirmationTarget_normal(void); +void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); /** - * Utility method to constructs a new HighPriority-variant ConfirmationTarget + * Constructs a new Ping given each field */ -enum LDKConfirmationTarget ConfirmationTarget_high_priority(void); +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); /** - * Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. + * Creates a copy of the Ping */ -uint64_t ConfirmationTarget_hash(const enum LDKConfirmationTarget *NONNULL_PTR o); +struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); /** - * Checks if two ConfirmationTargets contain equal inner contents. + * Checks if two Pings 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. */ -bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, const enum LDKConfirmationTarget *NONNULL_PTR b); +bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); /** - * Calls the free function if one is set + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. */ -void FeeEstimator_free(struct LDKFeeEstimator this_ptr); +void Pong_free(struct LDKPong this_obj); /** - * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. */ -void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); +uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); /** - * Creates a copy of the MonitorUpdateId + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. */ -struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); +void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. + * Constructs a new Pong given each field */ -uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); /** - * Checks if two MonitorUpdateIds contain equal inner contents. + * Creates a copy of the Pong + */ +struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); + +/** + * Checks if two Pongs 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. */ -bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); +bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); /** - * Calls the free function if one is set + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ -void Persist_free(struct LDKPersist this_ptr); +void OpenChannel_free(struct LDKOpenChannel this_obj); /** - * Frees any resources used by the LockedChannelMonitor, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain where the channel is to be opened */ -void LockedChannelMonitor_free(struct LDKLockedChannelMonitor this_obj); +const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the ChainMonitor, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain where the channel is to be opened */ -void ChainMonitor_free(struct LDKChainMonitor this_obj); +void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. - * - * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor - * will call back to it indicating transactions and outputs of interest. This allows clients to - * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may - * always need to fetch full blocks absent another means for determining which blocks contain - * transactions relevant to the watched channels. + * A temporary channel ID, until the funding outpoint is announced */ -MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister); +const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; /** - * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or - * claims which are awaiting confirmation. - * - * Includes the balances from each [`ChannelMonitor`] *except* those included in - * `ignored_channels`, allowing you to filter out balances from channels which are still open - * (and whose balance should likely be pulled from the [`ChannelDetails`]). - * - * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for - * inclusion in the return value. + * A temporary channel ID, until the funding outpoint is announced */ -MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels); +void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Gets the [`LockedChannelMonitor`] for a given funding outpoint, returning an `Err` if no - * such [`ChannelMonitor`] is currently being monitored for. - * - * Note that the result holds a mutex over our monitor set, and should not be held - * indefinitely. + * The channel value */ -MUST_USE_RES struct LDKCResult_LockedChannelMonitorNoneZ ChainMonitor_get_monitor(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo); +uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. - * - * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always - * monitoring for on-chain state resolutions. + * The channel value */ -MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Indicates the persistence of a [`ChannelMonitor`] has completed after - * [`ChannelMonitorUpdateStatus::InProgress`] 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 [`ChannelMonitorUpdateStatus::InProgress`], - * 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. + * The amount to push to the counterparty as part of the open, in milli-satoshi */ -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); +void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets a [`Future`] that completes when an event is available either via - * [`chain::Watch::release_pending_monitor_events`] or - * [`EventsProvider::process_pending_events`]. - * - * Note that callbacks registered on the [`Future`] MUST NOT call back into this - * [`ChainMonitor`] and should instead register actions to be taken later. - * - * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -MUST_USE_RES struct LDKFuture ChainMonitor_get_update_future(const struct LDKChainMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is - * crucial in preventing certain classes of pinning attacks, detecting substantial mempool - * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend - * invoking this every 30 seconds, or lower if running in an environment with spotty - * connections, like on mobile. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -void ChainMonitor_rebroadcast_pending_claims(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * 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 + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKListen ChainMonitor_as_Listen(const struct LDKChainMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKConfirm ChainMonitor_as_Confirm(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new Watch which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Watch must be freed before this_arg is + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKWatch ChainMonitor_as_Watch(const struct LDKChainMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKEventsProvider ChainMonitor_as_EventsProvider(const struct LDKChainMonitor *NONNULL_PTR this_arg); +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); +uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with two exceptions specified below. - * - * This sequence number is also used to track up to which points updates which returned - * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. - * - * The only instances we allow where update_id values are not strictly increasing have a - * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that - * will force close the channel by broadcasting the latest commitment transaction or - * special post-force-close updates, like providing preimages necessary to claim outputs on the - * broadcast commitment transaction. See its docs for more details. - * - * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress + * The minimum HTLC size incoming to sender, in milli-satoshi */ -uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); +void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The sequence number of this update. Updates *must* be replayed in-order according to this - * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with two exceptions specified below. - * - * This sequence number is also used to track up to which points updates which returned - * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given - * ChannelMonitor when ChannelManager::channel_monitor_updated is called. - * - * The only instances we allow where update_id values are not strictly increasing have a - * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that - * will force close the channel by broadcasting the latest commitment transaction or - * special post-force-close updates, like providing preimages necessary to claim outputs on the - * broadcast commitment transaction. See its docs for more details. - * - * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress + * The feerate per 1000-weight of sender generated transactions, until updated by + * [`UpdateFee`] */ -void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); +uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelMonitorUpdate + * The feerate per 1000-weight of sender generated transactions, until updated by + * [`UpdateFee`] */ -struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); +void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two ChannelMonitorUpdates 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. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if + * they broadcast a commitment transaction */ -bool ChannelMonitorUpdate_eq(const struct LDKChannelMonitorUpdate *NONNULL_PTR a, const struct LDKChannelMonitorUpdate *NONNULL_PTR b); +uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read + * The number of blocks which the counterparty will have to wait to claim on-chain funds if + * they broadcast a commitment transaction */ -struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpdate *NONNULL_PTR obj); +void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write + * The maximum number of inbound HTLCs towards sender */ -struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); +uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the MonitorEvent + * The maximum number of inbound HTLCs towards sender */ -void MonitorEvent_free(struct LDKMonitorEvent this_ptr); +void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a copy of the MonitorEvent + * The sender's key controlling the funding transaction */ -struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_PTR orig); +struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new HTLCEvent-variant MonitorEvent + * The sender's key controlling the funding transaction */ -struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); +void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a); +struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Completed-variant MonitorEvent + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); +void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new UpdateFailed-variant MonitorEvent + * A payment key to sender for transactions broadcast by counterparty */ -struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); +struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Checks if two MonitorEvents contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * A payment key to sender for transactions broadcast by counterparty */ -bool MonitorEvent_eq(const struct LDKMonitorEvent *NONNULL_PTR a, const struct LDKMonitorEvent *NONNULL_PTR b); +void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read + * Used to derive a payment key to sender for transactions broadcast by sender */ -struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj); +struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Read a MonitorEvent from a byte array, created by MonitorEvent_write + * Used to derive a payment key to sender for transactions broadcast by sender */ -struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser); +void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. + * Used to derive an HTLC payment key to sender */ -void HTLCUpdate_free(struct LDKHTLCUpdate this_obj); +struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the HTLCUpdate + * Used to derive an HTLC payment key to sender */ -struct LDKHTLCUpdate HTLCUpdate_clone(const struct LDKHTLCUpdate *NONNULL_PTR orig); +void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if two HTLCUpdates 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. + * The first to-be-broadcast-by-sender transaction's per commitment point */ -bool HTLCUpdate_eq(const struct LDKHTLCUpdate *NONNULL_PTR a, const struct LDKHTLCUpdate *NONNULL_PTR b); +struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj); +void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a HTLCUpdate from a byte array, created by HTLCUpdate_write + * The channel flags to be used */ -struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); +uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Balance + * The channel flags to be used */ -void Balance_free(struct LDKBalance this_ptr); +void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); /** - * Creates a copy of the Balance + * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close */ -struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); +struct LDKCOption_ScriptZ OpenChannel_get_shutdown_scriptpubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ClaimableOnChannelClose-variant Balance + * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close */ -struct LDKBalance Balance_claimable_on_channel_close(uint64_t claimable_amount_satoshis); +void OpenChannel_set_shutdown_scriptpubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKCOption_ScriptZ val); /** - * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height); +struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ContentiousClaimable-variant Balance + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height); +void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance + * Constructs a new OpenChannel given each field */ -struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t claimable_height); +MUST_USE_RES struct LDKOpenChannel OpenChannel_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t push_msat_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t channel_reserve_satoshis_arg, uint64_t htlc_minimum_msat_arg, uint32_t feerate_per_kw_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_ScriptZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); /** - * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance + * Creates a copy of the OpenChannel */ -struct LDKBalance Balance_maybe_preimage_claimable_htlc(uint64_t claimable_amount_satoshis, uint32_t expiry_height); +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); /** - * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance + * Checks if two OpenChannels 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. */ -struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t claimable_amount_satoshis); +bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); /** - * Checks if two Balances contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. */ -bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); +void OpenChannelV2_free(struct LDKOpenChannelV2 this_obj); + +/** + * The genesis hash of the blockchain where the channel is to be opened + */ +const uint8_t (*OpenChannelV2_get_chain_hash(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain where the channel is to be opened */ -void ChannelMonitor_free(struct LDKChannelMonitor this_obj); +void OpenChannelV2_set_chain_hash(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read + * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint */ -struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_PTR obj); +const uint8_t (*OpenChannelV2_get_temporary_channel_id(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr))[32]; /** - * Updates a ChannelMonitor on the basis of some new information provided by the Channel - * itself. - * - * panics if the given update is not the next update by update_id. + * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); +void OpenChannelV2_set_temporary_channel_id(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this - * ChannelMonitor. + * The feerate for the funding transaction set by the channel initiator */ -MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint32_t OpenChannelV2_get_funding_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for. + * The feerate for the funding transaction set by the channel initiator */ -MUST_USE_RES struct LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +void OpenChannelV2_set_funding_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); /** - * Gets a list of txids, with their output scripts (in the order they appear in the - * transaction), which we must learn about spends of via block_connected(). + * The feerate for the commitment transaction set by the channel initiator */ -MUST_USE_RES struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ChannelMonitor_get_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint32_t OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly - * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs - * have been registered. + * The feerate for the commitment transaction set by the channel initiator */ -void ChannelMonitor_load_outputs_to_watch(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKFilter *NONNULL_PTR filter); +void OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); /** - * Get the list of HTLCs who's status has been updated on chain. This should be called by - * ChannelManager via [`chain::Watch::release_pending_monitor_events`]. + * Part of the channel value contributed by the channel initiator */ -MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannelV2_get_funding_satoshis(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. - * - * This is called by the [`EventsProvider::process_pending_events`] implementation for - * [`ChainMonitor`]. - * - * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events - * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor + * Part of the channel value contributed by the channel initiator */ -MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +void OpenChannelV2_set_funding_satoshis(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets the `node_id` of the counterparty for this channel. - * - * Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some` - * otherwise. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted */ -MUST_USE_RES struct LDKPublicKey ChannelMonitor_get_counterparty_node_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint64_t OpenChannelV2_get_dust_limit_satoshis(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of - * the Channel was out-of-date. - * - * You may also use this to broadcast the latest local commitment transaction, either because - * a monitor update failed with [`ChannelMonitorUpdateStatus::PermanentFailure`] or because we've - * fallen behind (i.e. we've received proof that our counterparty side knows a revocation - * secret we gave them that they shouldn't know). - * - * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty - * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't - * close channel with their commitment transaction after a substantial amount of time. Best - * may be to contact the other node operator out-of-band to coordinate other options available - * to you. In any-case, the choice is up to you. - * - * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted */ -MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); +void OpenChannelV2_set_dust_limit_satoshis(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Processes transactions in a newly connected block, which may result in any of the following: - * - update the monitor's state against resolved HTLCs - * - punish the counterparty in the case of seeing a revoked commitment transaction - * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration - * - detect settled outputs for later spending - * - schedule and bump any in-flight claims - * - * Returns any new outputs to watch from `txdata`; after called, these are also included in - * [`get_outputs_to_watch`]. - * - * [`get_outputs_to_watch`]: #method.get_outputs_to_watch + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_block_connected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +uint64_t OpenChannelV2_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Determines if the disconnected block contained any transactions of interest and updates - * appropriately. + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi */ -void ChannelMonitor_block_disconnected(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void OpenChannelV2_set_max_htlc_value_in_flight_msat(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Processes transactions confirmed in a block with the given header and height, returning new - * outputs to watch. See [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_connected`]: Self::block_connected + * The minimum HTLC size incoming to channel initiator, in milli-satoshi */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_transactions_confirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +uint64_t OpenChannelV2_get_htlc_minimum_msat(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Processes a transaction that was reorganized out of the chain. - * - * Used instead of [`block_disconnected`] by clients that are notified of transactions rather - * than blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_disconnected`]: Self::block_disconnected + * The minimum HTLC size incoming to channel initiator, in milli-satoshi */ -void ChannelMonitor_transaction_unconfirmed(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*txid)[32], struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void OpenChannelV2_set_htlc_minimum_msat(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Updates the monitor with the current best chain tip, returning new outputs to watch. See - * [`block_connected`] for details. - * - * Used instead of [`block_connected`] by clients that are notified of transactions rather than - * blocks. See [`chain::Confirm`] for calling expectations. - * - * [`block_connected`]: Self::block_connected + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -MUST_USE_RES struct LDKCVec_TransactionOutputsZ ChannelMonitor_best_block_updated(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const uint8_t (*header)[80], uint32_t height, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +uint16_t OpenChannelV2_get_to_self_delay(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Returns the set of txids that should be monitored for re-organization out of the chain. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -MUST_USE_RES struct LDKCVec_C2Tuple_TxidBlockHashZZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +void OpenChannelV2_set_to_self_delay(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint16_t val); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * The maximum number of inbound HTLCs towards channel initiator */ -MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint16_t OpenChannelV2_get_max_accepted_htlcs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is - * crucial in preventing certain classes of pinning attacks, detecting substantial mempool - * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend - * invoking this every 30 seconds, or lower if running in an environment with spotty - * connections, like on mobile. + * The maximum number of inbound HTLCs towards channel initiator */ -void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); +void OpenChannelV2_set_max_accepted_htlcs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint16_t val); /** - * Gets the balances in this channel which are either claimable by us if we were to - * force-close the channel now or which are claimable on-chain (possibly awaiting - * confirmation). - * - * Any balances in the channel which are available on-chain (excluding on-chain fees) are - * included here until an [`Event::SpendableOutputs`] event has been generated for the - * balance, or until our counterparty has claimed the balance and accrued several - * confirmations on the claim transaction. - * - * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of - * LDK prior to 0.0.111, balances may not be fully captured if our counterparty broadcasted - * a revoked state. - * - * See [`Balance`] for additional details on the types of claimable balances which - * may be returned here and their meanings. + * The locktime for the funding transaction */ -MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +uint32_t OpenChannelV2_get_locktime(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write + * The locktime for the funding transaction */ -struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKEntropySource *NONNULL_PTR arg_a, const struct LDKSignerProvider *NONNULL_PTR arg_b); +void OpenChannelV2_set_locktime(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the OutPoint, if is_owned is set and inner is non-NULL. + * The channel initiator's key controlling the funding transaction */ -void OutPoint_free(struct LDKOutPoint this_obj); +struct LDKPublicKey OpenChannelV2_get_funding_pubkey(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The referenced transaction's txid. + * The channel initiator's key controlling the funding transaction */ -const uint8_t (*OutPoint_get_txid(const struct LDKOutPoint *NONNULL_PTR this_ptr))[32]; +void OpenChannelV2_set_funding_pubkey(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The referenced transaction's txid. + * Used to derive a revocation key for transactions broadcast by counterparty */ -void OutPoint_set_txid(struct LDKOutPoint *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKPublicKey OpenChannelV2_get_revocation_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The index of the referenced output in its transaction's vout. + * Used to derive a revocation key for transactions broadcast by counterparty */ -uint16_t OutPoint_get_index(const struct LDKOutPoint *NONNULL_PTR this_ptr); +void OpenChannelV2_set_revocation_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The index of the referenced output in its transaction's vout. + * A payment key to channel initiator for transactions broadcast by counterparty */ -void OutPoint_set_index(struct LDKOutPoint *NONNULL_PTR this_ptr, uint16_t val); +struct LDKPublicKey OpenChannelV2_get_payment_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Constructs a new OutPoint given each field + * A payment key to channel initiator for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKOutPoint OutPoint_new(struct LDKThirtyTwoBytes txid_arg, uint16_t index_arg); +void OpenChannelV2_set_payment_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the OutPoint + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator */ -struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); +struct LDKPublicKey OpenChannelV2_get_delayed_payment_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Checks if two OutPoints 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. + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator */ -bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b); +void OpenChannelV2_set_delayed_payment_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Generates a non-cryptographic 64-bit hash of the OutPoint. + * Used to derive an HTLC payment key to channel initiator */ -uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); +struct LDKPublicKey OpenChannelV2_get_htlc_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Convert an `OutPoint` to a lightning channel id. + * Used to derive an HTLC payment key to channel initiator */ -MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); +void OpenChannelV2_set_htlc_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the OutPoint object into a byte array which can be read by OutPoint_read + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point */ -struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj); +struct LDKPublicKey OpenChannelV2_get_first_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Read a OutPoint from a byte array, created by OutPoint_write + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point */ -struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser); +void OpenChannelV2_set_first_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +struct LDKPublicKey OpenChannelV2_get_second_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable. + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void OpenChannelV2_set_second_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The outpoint which is spendable. + * Channel flags */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +uint8_t OpenChannelV2_get_channel_flags(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * Per commitment point to derive the delayed payment key by key holder. + * Channel flags */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void OpenChannelV2_set_channel_flags(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint8_t val); /** - * Per commitment point to derive the delayed payment key by key holder. + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCOption_ScriptZ OpenChannelV2_get_shutdown_scriptpubkey(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void OpenChannelV2_set_shutdown_scriptpubkey(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKCOption_ScriptZ val); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +struct LDKChannelTypeFeatures OpenChannelV2_get_channel_type(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The output which is referenced by the given outpoint. + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. * - * Returns a copy of the field. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void OpenChannelV2_set_channel_type(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * The output which is referenced by the given outpoint. + * Optionally, a requirement that only confirmed inputs can be added */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +enum LDKCOption_NoneZ OpenChannelV2_get_require_confirmed_inputs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Optionally, a requirement that only confirmed inputs can be added */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void OpenChannelV2_set_require_confirmed_inputs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Constructs a new OpenChannelV2 given each field */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKOpenChannelV2 OpenChannelV2_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKThirtyTwoBytes temporary_channel_id_arg, uint32_t funding_feerate_sat_per_1000_weight_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKPublicKey second_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_ScriptZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Creates a copy of the OpenChannelV2 */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKOpenChannelV2 OpenChannelV2_clone(const struct LDKOpenChannelV2 *NONNULL_PTR orig); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Checks if two OpenChannelV2s 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. */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool OpenChannelV2_eq(const struct LDKOpenChannelV2 *NONNULL_PTR a, const struct LDKOpenChannelV2 *NONNULL_PTR b); /** - * The value of the channel which this output originated from, possibly indirectly. + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void AcceptChannel_free(struct LDKAcceptChannel this_obj); /** - * The value of the channel which this output originated from, possibly indirectly. + * A temporary channel ID, until the funding outpoint is announced */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new DelayedPaymentOutputDescriptor given each field + * A temporary channel ID, until the funding outpoint is announced */ -MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Checks if two DelayedPaymentOutputDescriptors 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. + * The threshold below which outputs on transactions broadcast by sender will be omitted */ -bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); +void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); +uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); +void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The outpoint which is spendable. + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The outpoint which is spendable. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The output which is referenced by the given outpoint. - * - * Returns a copy of the field. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); /** - * The output which is referenced by the given outpoint. + * Minimum depth of the funding transaction before the channel is considered open */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Minimum depth of the funding transaction before the channel is considered open */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * The value of the channel which this transactions spends. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * The value of the channel which this transactions spends. + * The maximum number of inbound HTLCs towards sender */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Constructs a new StaticPaymentOutputDescriptor given each field + * The maximum number of inbound HTLCs towards sender */ -MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * The sender's key controlling the funding transaction */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Checks if two StaticPaymentOutputDescriptors 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. + * The sender's key controlling the funding transaction */ -bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); +void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write + * Used to derive a revocation key for transactions broadcast by counterparty */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); +void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the SpendableOutputDescriptor + * A payment key to sender for transactions broadcast by counterparty */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the SpendableOutputDescriptor + * A payment key to sender for transactions broadcast by counterparty */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor + * Used to derive a payment key to sender for transactions broadcast by sender */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output); +struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor + * Used to derive a payment key to sender for transactions broadcast by sender */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); +void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Checks if two SpendableOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty */ -bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); +void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * The first to-be-broadcast-by-sender transaction's per commitment point */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Calls the free function if one is set + * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close */ -void ChannelSigner_free(struct LDKChannelSigner this_ptr); +struct LDKCOption_ScriptZ AcceptChannel_get_shutdown_scriptpubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close */ -void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); +void AcceptChannel_set_shutdown_scriptpubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKCOption_ScriptZ val); /** - * Calls the free function if one is set + * The channel type that this channel will represent. + * + * If this is `None`, we derive the channel type from the intersection of + * our feature bits with our counterparty's feature bits from the [`Init`] message. + * This is required to match the equivalent field in [`OpenChannel::channel_type`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void WriteableEcdsaChannelSigner_free(struct LDKWriteableEcdsaChannelSigner this_ptr); +struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); /** - * Creates a copy of the Recipient + * The channel type that this channel will represent. + * + * If this is `None`, we derive the channel type from the intersection of + * our feature bits with our counterparty's feature bits from the [`Init`] message. + * This is required to match the equivalent field in [`OpenChannel::channel_type`]. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); +void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Utility method to constructs a new Node-variant Recipient + * Constructs a new AcceptChannel given each field */ -enum LDKRecipient Recipient_node(void); +MUST_USE_RES struct LDKAcceptChannel AcceptChannel_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t channel_reserve_satoshis_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKCOption_ScriptZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); /** - * Utility method to constructs a new PhantomNode-variant Recipient + * Creates a copy of the AcceptChannel */ -enum LDKRecipient Recipient_phantom_node(void); +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Checks if two AcceptChannels 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. */ -void EntropySource_free(struct LDKEntropySource this_ptr); +bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); /** - * Calls the free function if one is set + * Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. */ -void NodeSigner_free(struct LDKNodeSigner this_ptr); +void AcceptChannelV2_free(struct LDKAcceptChannelV2 this_obj); /** - * Calls the free function if one is set + * The same `temporary_channel_id` received from the initiator's `open_channel2` message. */ -void SignerProvider_free(struct LDKSignerProvider this_ptr); +const uint8_t (*AcceptChannelV2_get_temporary_channel_id(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * The same `temporary_channel_id` received from the initiator's `open_channel2` message. */ -void InMemorySigner_free(struct LDKInMemorySigner this_obj); +void AcceptChannelV2_set_temporary_channel_id(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Part of the channel value contributed by the channel acceptor */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint64_t AcceptChannelV2_get_funding_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Part of the channel value contributed by the channel acceptor */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void AcceptChannelV2_set_funding_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Holder secret key for blinded revocation pubkey. + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint64_t AcceptChannelV2_get_dust_limit_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Holder secret key for blinded revocation pubkey. + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void AcceptChannelV2_set_dust_limit_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint64_t AcceptChannelV2_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void AcceptChannelV2_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Holder secret key used in an HTLC transaction. + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint64_t AcceptChannelV2_get_htlc_minimum_msat(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Holder secret key used in an HTLC transaction. + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void AcceptChannelV2_set_htlc_minimum_msat(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Minimum depth of the funding transaction before the channel is considered open */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint32_t AcceptChannelV2_get_minimum_depth(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Minimum depth of the funding transaction before the channel is considered open */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void AcceptChannelV2_set_minimum_depth(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint32_t val); /** - * Commitment seed. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +uint16_t AcceptChannelV2_get_to_self_delay(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Commitment seed. + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void AcceptChannelV2_set_to_self_delay(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a copy of the InMemorySigner + * The maximum number of inbound HTLCs towards channel acceptor */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +uint16_t AcceptChannelV2_get_max_accepted_htlcs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Creates a new [`InMemorySigner`]. + * The maximum number of inbound HTLCs towards channel acceptor */ -MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); +void AcceptChannelV2_set_max_accepted_htlcs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint16_t val); /** - * Returns the counterparty's pubkeys. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * The channel acceptor's key controlling the funding transaction */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_funding_pubkey(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable - * transactions, i.e., the amount of time that we have to wait to recover our funds if we - * broadcast a transaction. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * The channel acceptor's key controlling the funding transaction */ -MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AcceptChannelV2_set_funding_pubkey(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Returns the `contest_delay` value specified by us and applied on transactions broadcastable - * by our counterparty, i.e., the amount of time that they have to wait to recover their funds - * if they broadcast a transaction. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_revocation_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Returns whether the holder is the initiator. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Used to derive a revocation key for transactions broadcast by counterparty */ -MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AcceptChannelV2_set_revocation_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Funding outpoint - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * A payment key to channel acceptor for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_payment_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or - * building transactions. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * A payment key to channel acceptor for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AcceptChannelV2_set_payment_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Returns whether anchors should be used. - * - * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor */ -MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_delayed_payment_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described - * by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], - * or if an output descriptor `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor */ -MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); +void AcceptChannelV2_set_delayed_payment_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Sign the single input of `spend_tx` at index `input_idx` which spends the output - * described by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], does not have a - * sequence set to [`descriptor.to_self_delay`], or if an output descriptor - * `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint - * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ -MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +struct LDKPublicKey AcceptChannelV2_get_htlc_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty */ -struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AcceptChannelV2_set_htlc_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_first_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AcceptChannelV2_set_first_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -struct LDKWriteableEcdsaChannelSigner InMemorySigner_as_WriteableEcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKPublicKey AcceptChannelV2_get_second_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +void AcceptChannelV2_set_second_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); +struct LDKCOption_ScriptZ AcceptChannelV2_get_shutdown_scriptpubkey(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close */ -void KeysManager_free(struct LDKKeysManager this_obj); +void AcceptChannelV2_set_shutdown_scriptpubkey(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKCOption_ScriptZ val); /** - * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., - * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). - * `starting_time` isn't strictly required to actually be a time, but it must absolutely, - * without a doubt, be unique to this instance. ie if you start multiple times with the same - * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this - * is to simply use the current time (with very high precision). + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. * - * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, - * obviously, `starting_time` should be unique every time you reload the library - it is only - * used to generate new ephemeral key data (which will be stored by the individual channel if - * necessary). + * This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. * - * Note that the seed is required to recover certain on-chain funds independent of - * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required - * for any channel, and some on-chain during-closing funds. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures AcceptChannelV2_get_channel_type(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); + +/** + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +void AcceptChannelV2_set_channel_type(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Optionally, a requirement that only confirmed inputs can be added */ -MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); +enum LDKCOption_NoneZ AcceptChannelV2_get_require_confirmed_inputs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); /** - * Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. + * Optionally, a requirement that only confirmed inputs can be added */ -MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +void AcceptChannelV2_set_require_confirmed_inputs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an - * output to the given change destination (if sufficient change value remains). The - * transaction will have a feerate, at least, of the given value. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee, - * if a descriptor was duplicated, or if an output descriptor `script_pubkey` - * does not match the one we can spend. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. - * - * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used - * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. + * Constructs a new AcceptChannelV2 given each field */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); +MUST_USE_RES struct LDKAcceptChannelV2 AcceptChannelV2_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKPublicKey second_per_commitment_point_arg, struct LDKCOption_ScriptZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Creates a copy of the AcceptChannelV2 */ -struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKAcceptChannelV2 AcceptChannelV2_clone(const struct LDKAcceptChannelV2 *NONNULL_PTR orig); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * Checks if two AcceptChannelV2s 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. + */ +bool AcceptChannelV2_eq(const struct LDKAcceptChannelV2 *NONNULL_PTR a, const struct LDKAcceptChannelV2 *NONNULL_PTR b); + +/** + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + */ +void FundingCreated_free(struct LDKFundingCreated this_obj); + +/** + * A temporary channel ID, until the funding is established + */ +const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; + +/** + * A temporary channel ID, until the funding is established */ -struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * The funding transaction ID */ -struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + * The funding transaction ID */ -void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); +void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * The specific output index funding this channel */ -struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * The specific output index funding this channel */ -struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * The signature of the channel initiator (funder) on the initial commitment transaction */ -struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); /** - * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` - * that is shared across all nodes that intend to participate in [phantom node payments] - * together. - * - * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and - * `starting_time_nanos`. - * - * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the - * same across restarts, or else inbound payments may fail. - * - * [phantom node payments]: PhantomKeysManager + * The signature of the channel initiator (funder) on the initial commitment transaction */ -MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); +void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. + * Constructs a new FundingCreated given each field */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ PhantomKeysManager_spend_spendable_outputs(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); /** - * See [`KeysManager::derive_channel_keys`] for documentation on this method. + * Creates a copy of the FundingCreated */ -MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Checks if two FundingCreateds 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. */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); /** - * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the - * last-hop onion data, etc. + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void FundingSigned_free(struct LDKFundingSigned this_obj); /** - * Creates a copy of the FailureCode + * The channel ID */ -enum LDKFailureCode FailureCode_clone(const enum LDKFailureCode *NONNULL_PTR orig); +const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new TemporaryNodeFailure-variant FailureCode + * The channel ID */ -enum LDKFailureCode FailureCode_temporary_node_failure(void); +void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new RequiredNodeFeatureMissing-variant FailureCode + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -enum LDKFailureCode FailureCode_required_node_feature_missing(void); +struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new IncorrectOrUnknownPaymentDetails-variant FailureCode + * The signature of the channel acceptor (fundee) on the initial commitment transaction */ -enum LDKFailureCode FailureCode_incorrect_or_unknown_payment_details(void); +void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. + * Constructs a new FundingSigned given each field */ -void ChannelManager_free(struct LDKChannelManager this_obj); +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); /** - * Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL. + * Creates a copy of the FundingSigned */ -void ChainParameters_free(struct LDKChainParameters this_obj); +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); /** - * The network for determining the `chain_hash` in Lightning messages. + * Checks if two FundingSigneds 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. */ -enum LDKNetwork ChainParameters_get_network(const struct LDKChainParameters *NONNULL_PTR this_ptr); +bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); /** - * The network for determining the `chain_hash` in Lightning messages. + * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. */ -void ChainParameters_set_network(struct LDKChainParameters *NONNULL_PTR this_ptr, enum LDKNetwork val); +void ChannelReady_free(struct LDKChannelReady this_obj); /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * The channel ID */ -struct LDKBestBlock ChainParameters_get_best_block(const struct LDKChainParameters *NONNULL_PTR this_ptr); +const uint8_t (*ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr))[32]; /** - * The hash and height of the latest block successfully connected. - * - * Used to track on-chain channel funding outputs and send payments with reliable timelocks. + * The channel ID */ -void ChainParameters_set_best_block(struct LDKChainParameters *NONNULL_PTR this_ptr, struct LDKBestBlock val); +void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new ChainParameters given each field + * The per-commitment point of the second commitment transaction */ -MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork network_arg, struct LDKBestBlock best_block_arg); +struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChainParameters + * The per-commitment point of the second commitment transaction */ -struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); +void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ -void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); +struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); /** - * Base routing fee in millisatoshis. + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. */ -uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Base routing fee in millisatoshis. + * Constructs a new ChannelReady given each field */ -void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Creates a copy of the ChannelReady */ -uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Checks if two ChannelReadys 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. */ -void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. */ -uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +void TxAddInput_free(struct LDKTxAddInput this_obj); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * The channel ID */ -void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*TxAddInput_get_channel_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new CounterpartyForwardingInfo given each field + * The channel ID */ -MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); +void TxAddInput_set_channel_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the CounterpartyForwardingInfo + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); +uint64_t TxAddInput_get_serial_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); +void TxAddInput_set_serial_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint64_t val); /** - * The node_id of our counterparty + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +struct LDKTransactionU16LenLimited TxAddInput_get_prevtx(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The node_id of our counterparty + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void TxAddInput_set_prevtx(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKTransactionU16LenLimited val); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The index of the output being spent */ -struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +uint32_t TxAddInput_get_prevtx_out(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The index of the output being spent */ -void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void TxAddInput_set_prevtx_out(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * The sequence number of this input */ -uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * The sequence number of this input */ -void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); +void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new TxAddInput given each field */ -struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the TxAddInput */ -void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); +struct LDKTxAddInput TxAddInput_clone(const struct LDKTxAddInput *NONNULL_PTR orig); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Checks if two TxAddInputs 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. */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +bool TxAddInput_eq(const struct LDKTxAddInput *NONNULL_PTR a, const struct LDKTxAddInput *NONNULL_PTR b); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. */ -void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxAddOutput_free(struct LDKTxAddOutput this_obj); /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * The channel ID */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +const uint8_t (*TxAddOutput_get_channel_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr))[32]; /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * The channel ID */ -void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxAddOutput_set_channel_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new ChannelCounterparty given each field + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. */ -MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); +uint64_t TxAddOutput_get_serial_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * Creates a copy of the ChannelCounterparty + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. */ -struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); +void TxAddOutput_set_serial_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + * The satoshi value of the output */ -void ChannelDetails_free(struct LDKChannelDetails this_obj); +uint64_t TxAddOutput_get_sats(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * The satoshi value of the output */ -const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; +void TxAddOutput_set_sats(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * The scriptPubKey for the output */ -void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKu8slice TxAddOutput_get_script(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * The scriptPubKey for the output */ -struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxAddOutput_set_script(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * Constructs a new TxAddOutput given each field */ -void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); +MUST_USE_RES struct LDKTxAddOutput TxAddOutput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg, uint64_t sats_arg, struct LDKCVec_u8Z script_arg); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the TxAddOutput */ -struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxAddOutput TxAddOutput_clone(const struct LDKTxAddOutput *NONNULL_PTR orig); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. - * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two TxAddOutputs 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. */ -void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); +bool TxAddOutput_eq(const struct LDKTxAddOutput *NONNULL_PTR a, const struct LDKTxAddOutput *NONNULL_PTR b); /** - * The features which this channel operates with. See individual features for more info. - * - * `None` until negotiation completes and the channel type is finalized. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. */ -struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveInput_free(struct LDKTxRemoveInput this_obj); /** - * The features which this channel operates with. See individual features for more info. - * - * `None` until negotiation completes and the channel type is finalized. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel ID */ -void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +const uint8_t (*TxRemoveInput_get_channel_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr))[32]; /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. - * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. - * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. - * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required + * The channel ID */ -struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveInput_set_channel_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. - * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. - * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. - * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required + * The serial ID of the input to be removed */ -void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +uint64_t TxRemoveInput_get_serial_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). - * - * This will be `None` as long as the channel is not available for routing outbound payments. - * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * The serial ID of the input to be removed */ -struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveInput_set_serial_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, uint64_t val); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). - * - * This will be `None` as long as the channel is not available for routing outbound payments. - * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * Constructs a new TxRemoveInput given each field */ -void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKTxRemoveInput TxRemoveInput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. - * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. - * - * [`short_channel_id`]: Self::short_channel_id + * Creates a copy of the TxRemoveInput */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxRemoveInput TxRemoveInput_clone(const struct LDKTxRemoveInput *NONNULL_PTR orig); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. - * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. - * - * [`short_channel_id`]: Self::short_channel_id + * Checks if two TxRemoveInputs 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. */ -void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +bool TxRemoveInput_eq(const struct LDKTxRemoveInput *NONNULL_PTR a, const struct LDKTxRemoveInput *NONNULL_PTR b); /** - * The value, in satoshis, of this channel as appears in the funding output + * Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_free(struct LDKTxRemoveOutput this_obj); /** - * The value, in satoshis, of this channel as appears in the funding output + * The channel ID */ -void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*TxRemoveOutput_get_channel_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr))[32]; /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * The channel ID */ -struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_set_channel_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. - * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + * The serial ID of the output to be removed */ -void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +uint64_t TxRemoveOutput_get_serial_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); /** - * The `user_channel_id` passed in to create_channel, or a random value if the channel was - * inbound. This may be zero for inbound channels serialized with LDK versions prior to - * 0.0.113. + * The serial ID of the output to be removed */ -struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxRemoveOutput_set_serial_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * The `user_channel_id` passed in to create_channel, or a random value if the channel was - * inbound. This may be zero for inbound channels serialized with LDK versions prior to - * 0.0.113. + * Constructs a new TxRemoveOutput given each field */ -void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); +MUST_USE_RES struct LDKTxRemoveOutput TxRemoveOutput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg); /** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + * Creates a copy of the TxRemoveOutput */ -struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxRemoveOutput TxRemoveOutput_clone(const struct LDKTxRemoveOutput *NONNULL_PTR orig); /** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + * Checks if two TxRemoveOutputs 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. */ -void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +bool TxRemoveOutput_eq(const struct LDKTxRemoveOutput *NONNULL_PTR a, const struct LDKTxRemoveOutput *NONNULL_PTR b); /** - * Our total balance. This is the amount we would get if we close the channel. - * This value is not exact. Due to various in-flight changes and feerate changes, exactly this - * amount is not likely to be recoverable on close. - * - * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose - * balance is not available for inclusion in new outbound HTLCs). This further does not include - * any pending outgoing HTLCs which are awaiting some other resolution to be sent. - * This does not consider any on-chain fees. - * - * See also [`ChannelDetails::outbound_capacity_msat`] + * Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxComplete_free(struct LDKTxComplete this_obj); /** - * Our total balance. This is the amount we would get if we close the channel. - * This value is not exact. Due to various in-flight changes and feerate changes, exactly this - * amount is not likely to be recoverable on close. - * - * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose - * balance is not available for inclusion in new outbound HTLCs). This further does not include - * any pending outgoing HTLCs which are awaiting some other resolution to be sent. - * This does not consider any on-chain fees. - * - * See also [`ChannelDetails::outbound_capacity_msat`] + * The channel ID */ -void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*TxComplete_get_channel_id(const struct LDKTxComplete *NONNULL_PTR this_ptr))[32]; /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. - * - * See also [`ChannelDetails::balance_msat`] - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. + * The channel ID */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxComplete_set_channel_id(struct LDKTxComplete *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. - * - * See also [`ChannelDetails::balance_msat`] - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. + * Constructs a new TxComplete given each field */ -void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKTxComplete TxComplete_new(struct LDKThirtyTwoBytes channel_id_arg); /** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. - * - * See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. + * Creates a copy of the TxComplete */ -uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKTxComplete TxComplete_clone(const struct LDKTxComplete *NONNULL_PTR orig); /** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. - * - * See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. + * Checks if two TxCompletes 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. */ -void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +bool TxComplete_eq(const struct LDKTxComplete *NONNULL_PTR a, const struct LDKTxComplete *NONNULL_PTR b); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxSignatures_free(struct LDKTxSignatures this_obj); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. - * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * The channel ID */ -void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*TxSignatures_get_channel_id(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * The channel ID */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxSignatures_set_channel_id(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. - * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * The TXID */ -void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +const uint8_t (*TxSignatures_get_tx_hash(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; /** - * The current number of confirmations on the funding transaction. - * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + * The TXID */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxSignatures_set_tx_hash(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The current number of confirmations on the funding transaction. + * The list of witnesses * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + * Returns a copy of the field. */ -void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +struct LDKCVec_WitnessZ TxSignatures_get_witnesses(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * The list of witnesses */ -struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCVec_WitnessZ val); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. - * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Constructs a new TxSignatures given each field + */ +MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg); + +/** + * Creates a copy of the TxSignatures */ -void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); +struct LDKTxSignatures TxSignatures_clone(const struct LDKTxSignatures *NONNULL_PTR orig); /** - * True if the channel was initiated (and thus funded) by us. + * Checks if two TxSignaturess 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. */ -bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool TxSignatures_eq(const struct LDKTxSignatures *NONNULL_PTR a, const struct LDKTxSignatures *NONNULL_PTR b); /** - * True if the channel was initiated (and thus funded) by us. + * Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void TxInitRbf_free(struct LDKTxInitRbf this_obj); /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * The channel ID */ -bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +const uint8_t (*TxInitRbf_get_channel_id(const struct LDKTxInitRbf *NONNULL_PTR this_ptr))[32]; /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. - * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * The channel ID */ -void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void TxInitRbf_set_channel_id(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_channel_ready`. + * The locktime of the transaction */ -bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint32_t TxInitRbf_get_locktime(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. - * - * This is a strict superset of `is_channel_ready`. + * The locktime of the transaction */ -void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void TxInitRbf_set_locktime(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * True if this channel is (or will be) publicly-announced. + * The feerate of the transaction */ -bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +uint32_t TxInitRbf_get_feerate_sat_per_1000_weight(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * True if this channel is (or will be) publicly-announced. + * The feerate of the transaction */ -void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void TxInitRbf_set_feerate_sat_per_1000_weight(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +struct LDKCOption_i64Z TxInitRbf_get_funding_output_contribution(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void TxInitRbf_set_funding_output_contribution(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Constructs a new TxInitRbf given each field */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxInitRbf TxInitRbf_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t locktime_arg, uint32_t feerate_sat_per_1000_weight_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Creates a copy of the TxInitRbf */ -void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKTxInitRbf TxInitRbf_clone(const struct LDKTxInitRbf *NONNULL_PTR orig); /** - * Set of configurable parameters that affect channel operation. - * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two TxInitRbfs 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. */ -struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool TxInitRbf_eq(const struct LDKTxInitRbf *NONNULL_PTR a, const struct LDKTxInitRbf *NONNULL_PTR b); /** - * Set of configurable parameters that affect channel operation. - * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. */ -void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +void TxAckRbf_free(struct LDKTxAckRbf this_obj); /** - * Constructs a new ChannelDetails given each field + * The channel ID */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); +const uint8_t (*TxAckRbf_get_channel_id(const struct LDKTxAckRbf *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the ChannelDetails + * The channel ID */ -struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +void TxAckRbf_set_channel_id(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Gets the current SCID which should be used to identify this channel for inbound payments. - * This should be used for providing invoice hints or in any other context where our - * counterparty will forward a payment to us. - * - * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the - * [`ChannelDetails::short_channel_id`]. See those for more information. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +struct LDKCOption_i64Z TxAckRbf_get_funding_output_contribution(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); /** - * Gets the current SCID which should be used to identify this channel for outbound payments. - * This should be used in [`Route`]s to describe the first hop or in other contexts where - * we're sending or forwarding a payment outbound over this channel. - * - * This is either the [`ChannelDetails::short_channel_id`], if set, or the - * [`ChannelDetails::outbound_scid_alias`]. See those for more information. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +void TxAckRbf_set_funding_output_contribution(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * Frees any resources used by the RecentPaymentDetails + * Constructs a new TxAckRbf given each field */ -void RecentPaymentDetails_free(struct LDKRecentPaymentDetails this_ptr); +MUST_USE_RES struct LDKTxAckRbf TxAckRbf_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * Creates a copy of the RecentPaymentDetails + * Creates a copy of the TxAckRbf */ -struct LDKRecentPaymentDetails RecentPaymentDetails_clone(const struct LDKRecentPaymentDetails *NONNULL_PTR orig); +struct LDKTxAckRbf TxAckRbf_clone(const struct LDKTxAckRbf *NONNULL_PTR orig); /** - * Utility method to constructs a new Pending-variant RecentPaymentDetails + * Checks if two TxAckRbfs 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. */ -struct LDKRecentPaymentDetails RecentPaymentDetails_pending(struct LDKThirtyTwoBytes payment_hash, uint64_t total_msat); +bool TxAckRbf_eq(const struct LDKTxAckRbf *NONNULL_PTR a, const struct LDKTxAckRbf *NONNULL_PTR b); /** - * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails + * Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. */ -struct LDKRecentPaymentDetails RecentPaymentDetails_fulfilled(struct LDKThirtyTwoBytes payment_hash); +void TxAbort_free(struct LDKTxAbort this_obj); /** - * Utility method to constructs a new Abandoned-variant RecentPaymentDetails + * The channel ID */ -struct LDKRecentPaymentDetails RecentPaymentDetails_abandoned(struct LDKThirtyTwoBytes payment_hash); +const uint8_t (*TxAbort_get_channel_id(const struct LDKTxAbort *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. + * The channel ID */ -void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); +void TxAbort_set_channel_id(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The list of channels to be included in the invoice route hints. + * Message data + * + * Returns a copy of the field. */ -struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxAbort_get_data(const struct LDKTxAbort *NONNULL_PTR this_ptr); /** - * The list of channels to be included in the invoice route hints. + * Message data */ -void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); +void TxAbort_set_data(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Constructs a new TxAbort given each field */ -uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxAbort TxAbort_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z data_arg); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Creates a copy of the TxAbort */ -void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); +struct LDKTxAbort TxAbort_clone(const struct LDKTxAbort *NONNULL_PTR orig); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Checks if two TxAborts 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. */ -struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +bool TxAbort_eq(const struct LDKTxAbort *NONNULL_PTR a, const struct LDKTxAbort *NONNULL_PTR b); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ -void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void Shutdown_free(struct LDKShutdown this_obj); /** - * Constructs a new PhantomRouteHints given each field + * The channel ID */ -MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); +const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the PhantomRouteHints + * The channel ID */ -struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); +void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new `ChannelManager` to hold several channels and route between them. - * - * This is the main \"logic hub\" for all channel-related actions, and implements - * [`ChannelMessageHandler`]. - * - * Non-proportional fees are fixed according to our risk using the provided fee estimator. - * - * Users need to notify the new `ChannelManager` when a new block is connected or - * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting - * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for - * more details. + * The destination of this peer's funds on closing. * - * [`block_connected`]: chain::Listen::block_connected - * [`block_disconnected`]: chain::Listen::block_disconnected - * [`params.best_block.block_hash`]: chain::BestBlock::block_hash + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKUserConfig config, struct LDKChainParameters params); +struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * Gets the current configuration applied to all new channels. + * The destination of this peer's funds on closing. + * + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); +void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a new outbound channel to the given remote node and with the given value. - * - * `user_channel_id` will be provided back as in - * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events - * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a - * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it - * is simply copied to events and otherwise ignored. - * - * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is - * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. - * - * Note that we do not check if you are currently connected to the given peer. If no - * connection is available, the outbound `open_channel` message may fail to send, resulting in - * the channel eventually being silently forgotten (dropped on reload). - * - * Returns the new Channel's temporary `channel_id`. This ID will appear as - * [`Event::FundingGenerationReady::temporary_channel_id`] and in - * [`ChannelDetails::channel_id`] until after - * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for - * one derived from the funding transaction's TXID. If the counterparty rejects the channel - * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. - * - * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id - * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id - * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id - * - * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new Shutdown given each field */ -MUST_USE_RES struct LDKCResult__u832APIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, struct LDKU128 user_channel_id, struct LDKUserConfig override_config); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); /** - * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for - * more information. + * Creates a copy of the Shutdown */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); /** - * Gets the list of usable channels, in random order. Useful as an argument to - * [`Router::find_route`] to ensure non-announced channels are used. - * - * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the - * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria - * are. + * Checks if two Shutdowns 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. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); /** - * Gets the list of channels we have with a given counterparty, in random order. + * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels_with_counterparty(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); +void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); /** - * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a - * successful path, or have unresolved HTLCs. - * - * This can be useful for payments that may have been prepared, but ultimately not sent, as a - * result of a crash. If such a payment exists, is not listed here, and an - * [`Event::PaymentSent`] has not been received, you may consider resending the payment. - * - * [`Event::PaymentSent`]: events::Event::PaymentSent + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKCVec_RecentPaymentDetailsZ ChannelManager_list_recent_payments(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * * If we are the channel initiator, we will pay between our [`Background`] and - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee - * estimate. - * * If our counterparty is the channel initiator, we will require a channel closing - * transaction feerate of at least our [`Background`] feerate or the feerate which - * would appear on a force-closure transaction, whichever is lower. We will allow our - * counterparty to pay as much fee as they'd like, however. - * - * May generate a [`SendShutdown`] message event on success, which should be relayed. - * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated - * the channel being closed or not: - * * If we are the channel initiator, we will pay at least this feerate on the closing - * transaction. The upper-bound is set by - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee - * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). - * * If our counterparty is the channel initiator, we will refuse to accept a channel closure - * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which - * will appear on a force-closure transaction, whichever is lower). - * - * May generate a [`SendShutdown`] message event on success, which should be relayed. - * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background - * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal - * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_target_feerate(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id, uint32_t target_feerate_sats_per_1000_weight); +uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Force closes a channel, immediately broadcasting the latest local transaction(s) and - * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to - * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding - * channel. + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting - * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the - * `counterparty_node_id` isn't the counterparty of the corresponding channel. - * - * You can always get the latest local transaction(s) to broadcast from - * [`ChannelMonitor::get_latest_holder_commitment_txn`]. + * Constructs a new ClosingSignedFeeRange given each field */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); /** - * Force close all channels, immediately broadcasting the latest local commitment transaction - * for each to the chain and rejecting new HTLCs on each. + * Creates a copy of the ClosingSignedFeeRange */ -void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); /** - * Force close all channels rejecting new HTLCs on each but without broadcasting the latest - * local transaction(s). + * Checks if two ClosingSignedFeeRanges 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. */ -void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); /** - * Sends a payment along a given route. - * - * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] - * fields for more info. - * - * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via - * [`PeerManager::process_events`]). - * - * # Avoiding Duplicate Payments - * - * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this - * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment - * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an - * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a - * second payment with the same [`PaymentId`]. - * - * Thus, in order to ensure duplicate payments are not sent, you should implement your own - * tracking of payments, including state to indicate once a payment has completed. Because you - * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should - * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the - * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes. - * - * Additionally, in the scenario where we begin the process of sending a payment, but crash - * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're - * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See - * [`ChannelManager::list_recent_payments`] for more information. - * - * # Possible Error States on [`PaymentSendFailure`] - * - * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with - * each entry matching the corresponding-index entry in the route paths, see - * [`PaymentSendFailure`] for more info. - * - * In general, a path may raise: - * * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee, - * node public key) is specified. - * * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates - * (including due to previous monitor update failure or new permanent monitor update - * failure). - * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the - * relevant updates. - * - * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been - * irrevocably committed to on our end. In such a case, do NOT retry the payment with a - * different route unless you intend to pay twice! - * - * [`Event::PaymentSent`]: events::Event::PaymentSent - * [`Event::PaymentFailed`]: events::Event::PaymentFailed - * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events - * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** - * Similar to [`ChannelManager::send_payment`], but will automatically find a route based on - * `route_params` and retry failed payment paths based on `retry_strategy`. + * The channel ID */ -MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; /** - * Signals that no further retries for the given payment should occur. Useful if you have a - * pending outbound payment with retries remaining, but wish to stop retrying the payment before - * retries are exhausted. - * - * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon - * as there are no remaining pending HTLCs for this payment. - * - * Note that calling this method does *not* prevent a payment from succeeding. You must still - * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to - * determine the ultimate status of a payment. - * - * If an [`Event::PaymentFailed`] event is generated and we restart without this - * [`ChannelManager`] having been persisted, another [`Event::PaymentFailed`] may be generated. - * - * [`Event::PaymentFailed`]: events::Event::PaymentFailed - * [`Event::PaymentSent`]: events::Event::PaymentSent + * The channel ID */ -void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Send a spontaneous payment, which is a payment that does not require the recipient to have - * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify - * the preimage, it must be a cryptographically secure random value that no intermediate node - * would be able to guess -- otherwise, an intermediate node may claim the payment and it will - * never reach the recipient. - * - * See [`send_payment`] documentation for more details on the return value of this function - * and idempotency guarantees provided by the [`PaymentId`] key. - * - * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See - * [`send_payment`] for more information about the risks of duplicate preimage usage. - * - * Note that `route` must have exactly one path. - * - * [`send_payment`]: Self::send_payment - * - * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None + * The proposed total fee for the closing transaction */ -MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route - * based on `route_params` and retry failed payment paths based on `retry_strategy`. - * - * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous - * payments. - * - * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend - * - * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None + * The proposed total fee for the closing transaction */ -MUST_USE_RES struct LDKCResult_PaymentHashRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); /** - * Send a payment that is probing the given route for liquidity. We calculate the - * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows - * us to easily discern them from real payments. + * A signature on the closing transaction */ -MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPath path); +struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Call this upon creation of a funding transaction for the given channel. - * - * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs - * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. - * - * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation - * across the p2p network. - * - * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided - * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. - * - * May panic if the output found in the funding transaction is duplicative with some other - * channel (note that this should be trivially prevented by using unique funding transaction - * keys per-channel). - * - * Do NOT broadcast the funding transaction yourself. When we have safely received our - * counterparty's signature the funding transaction will automatically be broadcast via the - * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. - * - * Note that this includes RBF or similar transaction replacement strategies - lightning does - * not currently support replacing a funding transaction on an existing channel. Instead, - * create a new channel with a conflicting funding transaction. - * - * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend - * the wallet software generating the funding transaction to apply anti-fee sniping as - * implemented by Bitcoin Core wallet. See - * for more details. - * - * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady - * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed + * A signature on the closing transaction */ -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 LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); +void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Atomically updates the [`ChannelConfig`] for the given channels. - * - * Once the updates are applied, each eligible channel (advertised with a known short channel - * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], - * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated - * containing the new [`ChannelUpdate`] message which should be broadcast to the network. - * - * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect - * `counterparty_node_id` is provided. - * - * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value - * below [`MIN_CLTV_EXPIRY_DELTA`]. - * - * If an error is returned, none of the updates should be considered applied. + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths - * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat - * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta - * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`ChannelUnavailable`]: APIError::ChannelUnavailable - * [`APIMisuseError`]: APIError::APIMisuseError + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfig *NONNULL_PTR config); +struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Attempts to forward an intercepted HTLC over the provided channel id and with the provided - * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event. - * - * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time - * channel to a receiving node if the node lacks sufficient inbound liquidity. - * - * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use - * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the - * receiver's invoice route hints. These route hints will signal to LDK to generate an - * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or - * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. - * - * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop - * you from forwarding more than you received. - * - * Errors if the event was not handled in time, in which case the HTLC was automatically failed - * backwards. + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. * - * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_forward_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id, const uint8_t (*next_hop_channel_id)[32], struct LDKPublicKey next_node_id, uint64_t amt_to_forward_msat); +void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); /** - * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to - * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`]. - * - * Errors if the event was not handled in time, in which case the HTLC was automatically failed - * backwards. - * - * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + * Constructs a new ClosingSigned given each field */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_fail_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id); +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); /** - * Processes HTLCs which are pending waiting on random forward delay. - * - * Should only really ever be called in response to a PendingHTLCsForwardable event. - * Will likely generate further events. + * Creates a copy of the ClosingSigned */ -void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); /** - * Performs actions which should happen on startup and roughly once per minute thereafter. - * - * This currently includes: - * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, - * * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more - * than a minute, informing the network that they should no longer attempt to route over - * the channel. - * * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs - * with the current [`ChannelConfig`]. - * * Removing peers which have disconnected but and no longer have any channels. - * - * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate - * estimate fetches. - * - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`ChannelConfig`]: crate::util::config::ChannelConfig + * Checks if two ClosingSigneds 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. */ -void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); /** - * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect - * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources - * along the path (including in our own channel on which we received it). - * - * Note that in some cases around unclean shutdown, it is possible the payment may have - * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a - * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment - * may have already been failed automatically by LDK if it was nearing its expiration time. - * - * While LDK will never claim a payment automatically on your behalf (i.e. without you calling - * [`ChannelManager::claim_funds`]), you should still monitor for - * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on - * startup during which time claims that were in-progress at shutdown may be replayed. + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ -void ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); /** - * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the - * reason for the failure. - * - * See [`FailureCode`] for valid failure codes. + * The channel ID */ -void ChannelManager_fail_htlc_backwards_with_reason(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32], enum LDKFailureCode failure_code); +const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any - * [`MessageSendEvent`]s needed to claim the payment. - * - * This method is guaranteed to ensure the payment has been claimed but only if the current - * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race - * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment - * successful. It will generally be available in the next [`process_pending_events`] call. - * - * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or - * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` - * event matches your expectation. If you fail to do so and call this method, you may provide - * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. - * - * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable - * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline - * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed - * [`process_pending_events`]: EventsProvider::process_pending_events - * [`create_inbound_payment`]: Self::create_inbound_payment - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * The channel ID */ -void ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Gets the node_id held by this ChannelManager + * The HTLC ID */ -MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Accepts a request to open a channel after a [`Event::OpenChannelRequest`]. - * - * The `temporary_channel_id` parameter indicates which inbound channel should be accepted, - * and the `counterparty_node_id` parameter is the id of the peer which has requested to open - * the channel. - * - * The `user_channel_id` parameter will be provided back in - * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond - * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. - * - * Note that this method will return an error and reject the channel, if it requires support - * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be - * used to accept such channels. - * - * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest - * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + * The HTLC ID */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating - * it as confirmed immediately. - * - * The `user_channel_id` parameter will be provided back in - * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond - * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. - * - * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel - * and (if the counterparty agrees), enables forwarding of payments immediately. - * - * This fully trusts that the counterparty has honestly and correctly constructed the funding - * transaction and blindly assumes that it will eventually confirm. - * - * If it does not confirm before we decide to close the channel, or if the funding transaction - * does not pay to the correct script the correct amount, *you will lose funds*. - * - * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest - * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + * The HTLC value in milli-satoshi */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Gets a payment secret and payment hash for use in an invoice given to a third party wishing - * to pay us. - * - * This differs from [`create_inbound_payment_for_hash`] only in that it generates the - * [`PaymentHash`] and [`PaymentPreimage`] for you. - * - * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which - * will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with - * its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be - * passed directly to [`claim_funds`]. - * - * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. - * - * Note that a malicious eavesdropper can intuit whether an inbound payment was created by - * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. - * - * # Note - * - * If you register an inbound payment with this method, then serialize the `ChannelManager`, then - * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. - * - * Errors if `min_value_msat` is greater than total bitcoin supply. - * - * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [`claim_funds`]: Self::claim_funds - * [`PaymentClaimable`]: events::Event::PaymentClaimable - * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose - * [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment - * [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * The HTLC value in milli-satoshi */ -MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share - * serialized state with LDK node(s) running 0.0.103 and earlier. - * - * May panic if `invoice_expiry_delta_secs` is greater than one year. - * - * # Note - * This method is deprecated and will be removed soon. - * - * [`create_inbound_payment`]: Self::create_inbound_payment + * The payment hash, the pre-image of which controls HTLC redemption */ -MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ChannelManager_create_inbound_payment_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is - * stored external to LDK. - * - * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a - * payment secret fetched via this method or [`create_inbound_payment`], and which is at least - * the `min_value_msat` provided here, if one is provided. - * - * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though - * note that LDK will not stop you from registering duplicate payment hashes for inbound - * payments. - * - * `min_value_msat` should be set if the invoice being generated contains a value. Any payment - * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` - * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the - * sender \"proof-of-payment\" unless they have paid the required amount. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. This should roughly match the expiry time set in the invoice. - * After this many seconds, we will remove the inbound payment, resulting in any attempts to - * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for - * invoices when no timeout is set. - * - * Note that we use block header time to time-out pending inbound payments (with some margin - * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will - * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. - * If you need exact expiry semantics, you should enforce them upon receipt of - * [`PaymentClaimable`]. - * - * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` - * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * - * Note that a malicious eavesdropper can intuit whether an inbound payment was created by - * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. - * - * # Note - * - * If you register an inbound payment with this method, then serialize the `ChannelManager`, then - * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. - * - * Errors if `min_value_msat` is greater than total bitcoin supply. - * - * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [`create_inbound_payment`]: Self::create_inbound_payment - * [`PaymentClaimable`]: events::Event::PaymentClaimable + * The payment hash, the pre-image of which controls HTLC redemption */ -MUST_USE_RES struct LDKCResult_PaymentSecretNoneZ 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, struct LDKCOption_u16Z min_final_cltv_expiry); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share - * serialized state with LDK node(s) running 0.0.103 and earlier. - * - * May panic if `invoice_expiry_delta_secs` is greater than one year. - * - * # Note - * This method is deprecated and will be removed soon. - * - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * The expiry height of the HTLC */ -MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Gets an LDK-generated payment preimage from a payment hash and payment secret that were - * previously returned from [`create_inbound_payment`]. - * - * [`create_inbound_payment`]: Self::create_inbound_payment + * The expiry height of the HTLC */ -MUST_USE_RES struct LDKCResult_PaymentPreimageAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids - * are used when constructing the phantom invoice's route hints. + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCOption_u64Z UpdateAddHTLC_get_skimmed_fee_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Gets route hints for use in receiving [phantom node payments]. + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); +void UpdateAddHTLC_set_skimmed_fee_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are - * used when constructing the route hints for HTLCs intended to be intercepted. See - * [`ChannelManager::forward_intercepted_htlc`]. - * - * Note that this method is not guaranteed to return unique values, you may need to call it a few - * times to get a unique scid. + * Creates a copy of the UpdateAddHTLC */ -MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); /** - * Gets inflight HTLC information by processing pending outbound payments that are in - * our channels. May be used during pathfinding to account for in-use channel liquidity. + * Checks if two UpdateAddHTLCs 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. */ -MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. */ -struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OnionMessage_free(struct LDKOnionMessage this_obj); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Used in decrypting the onion packet's payload. */ -struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * 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 + * Used in decrypting the onion packet's payload. */ -struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); +void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * Creates a copy of the OnionMessage */ -struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); /** - * Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted. - * - * Note that callbacks registered on the [`Future`] MUST NOT call back into this - * [`ChannelManager`] and should instead register actions to be taken later. - * + * Checks if two OnionMessages 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. */ -MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** - * Fetches the set of [`NodeFeatures`] flags which are provided by or required by - * [`ChannelManager`]. + * The channel ID */ -MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by - * [`ChannelManager`]. + * The channel ID */ -MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by - * [`ChannelManager`]. + * The HTLC ID */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * Fetches the set of [`InitFeatures`] flags which are provided by or required by - * [`ChannelManager`]. + * The HTLC ID */ -MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * The pre-image of the payment hash, allowing HTLC redemption */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * Fetches the set of [`InitFeatures`] flags which are provided by or required by - * [`ChannelManager`]. + * The pre-image of the payment hash, allowing HTLC redemption */ -struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR _config); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + * Constructs a new UpdateFulfillHTLC given each field */ -struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); /** - * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + * Creates a copy of the UpdateFulfillHTLC */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); /** - * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + * Checks if two UpdateFulfillHTLCs 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. */ -struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); +bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); /** - * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** - * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + * The channel ID */ -struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); +const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; /** - * Read a ChannelDetails from a byte array, created by ChannelDetails_write + * The channel ID */ -struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read + * The HTLC ID */ -struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + * The HTLC ID */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + * Creates a copy of the UpdateFailHTLC */ -struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + * Checks if two UpdateFailHTLCs 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. */ -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); +bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); /** - * A cryptographically secure source of entropy. + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ -const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** - * A cryptographically secure source of entropy. + * The channel ID */ -void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); +const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; /** - * A signer that is able to perform node-scoped cryptographic operations. + * The channel ID */ -const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * A signer that is able to perform node-scoped cryptographic operations. + * The HTLC ID */ -void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The HTLC ID */ -const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The failure code */ -void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * The failure code */ -const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * Creates a copy of the UpdateFailMalformedHTLC */ -void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Checks if two UpdateFailMalformedHTLCs 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. */ -const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ -void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The channel ID */ -const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The channel ID */ -void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. - * - * No calls to the router will be made during deserialization. + * A signature on the commitment transaction */ -const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * A signature on the commitment transaction + */ +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); + +/** + * Signatures on the HTLC transactions * - * No calls to the router will be made during deserialization. + * Returns a copy of the field. */ -void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); +struct LDKCVec_SignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Signatures on the HTLC transactions */ -const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Constructs a new CommitmentSigned given each field */ -void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Creates a copy of the CommitmentSigned */ -struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Checks if two CommitmentSigneds 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. */ -void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); +bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); /** - * Simple utility function to create a ChannelManagerReadArgs which creates the monitor - * HashMap for you. This is primarily useful for C bindings where it is not practical to - * populate a HashMap directly from C. + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** - * Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write + * The channel ID */ -struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ C2Tuple_BlockHashChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); +const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. + * The channel ID */ -void ExpandedKey_free(struct LDKExpandedKey this_obj); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. - * - * It is recommended to cache this value and not regenerate it for each new inbound payment. + * The secret corresponding to the per-commitment point */ -MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(const uint8_t (*key_material)[32]); +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no - * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without - * a `ChannelManager`. - * - * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then - * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not - * regenerate it for each new inbound payment. - * - * `current_time` is a Unix timestamp representing the current time. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager - * [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material + * The secret corresponding to the per-commitment point */ -struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], - * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] - * without a `ChannelManager`. - * - * See [`create`] for information on the `keys` and `current_time` parameters. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + * The next sender-broadcast commitment transaction's per-commitment point */ -struct LDKCResult_PaymentSecretNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DecodeError + * The next sender-broadcast commitment transaction's per-commitment point */ -void DecodeError_free(struct LDKDecodeError this_ptr); +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the DecodeError + * Constructs a new RevokeAndACK given each field */ -struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * Utility method to constructs a new UnknownVersion-variant DecodeError + * Creates a copy of the RevokeAndACK */ -struct LDKDecodeError DecodeError_unknown_version(void); +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); /** - * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + * Checks if two RevokeAndACKs 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. */ -struct LDKDecodeError DecodeError_unknown_required_feature(void); +bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); /** - * Utility method to constructs a new InvalidValue-variant DecodeError + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ -struct LDKDecodeError DecodeError_invalid_value(void); +void UpdateFee_free(struct LDKUpdateFee this_obj); /** - * Utility method to constructs a new ShortRead-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_short_read(void); +const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_bad_length_descriptor(void); +void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new Io-variant DecodeError + * Fee rate per 1000-weight of the transaction */ -struct LDKDecodeError DecodeError_io(enum LDKIOError a); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnsupportedCompression-variant DecodeError + * Fee rate per 1000-weight of the transaction */ -struct LDKDecodeError DecodeError_unsupported_compression(void); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two DecodeErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new UpdateFee given each field */ -bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); /** - * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateFee */ -void Init_free(struct LDKInit this_obj); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); /** - * The relevant features which the sender supports. + * Checks if two UpdateFees 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. */ -struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); +bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); /** - * The relevant features which the sender supports. + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ -void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * The channel ID */ -struct LDKCOption_NetAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); +const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * The channel ID */ -void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_NetAddressZ val); +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new Init given each field + * The next commitment number for the sender */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_NetAddressZ remote_network_address_arg); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Creates a copy of the Init + * The next commitment number for the sender */ -struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two Inits 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. + * The next commitment number for the recipient */ -bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + * The next commitment number for the recipient */ -void ErrorMessage_free(struct LDKErrorMessage this_obj); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel ID involved in the error. - * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; +const uint8_t (*ChannelReestablish_get_your_last_per_commitment_secret(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** - * The channel ID involved in the error. - * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelReestablish_set_your_last_per_commitment_secret(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The sender's per-commitment point for their current commitment transaction */ -struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +struct LDKPublicKey ChannelReestablish_get_my_current_per_commitment_point(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The sender's per-commitment point for their current commitment transaction */ -void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void ChannelReestablish_set_my_current_per_commitment_point(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ErrorMessage given each field + * The next funding transaction ID */ -MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +struct LDKCOption_TxidZ ChannelReestablish_get_next_funding_txid(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Creates a copy of the ErrorMessage + * The next funding transaction ID */ -struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +void ChannelReestablish_set_next_funding_txid(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKCOption_TxidZ val); /** - * Checks if two ErrorMessages 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. + * Constructs a new ChannelReestablish given each field */ -bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); +MUST_USE_RES struct LDKChannelReestablish ChannelReestablish_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t next_local_commitment_number_arg, uint64_t next_remote_commitment_number_arg, struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg, struct LDKCOption_TxidZ next_funding_txid_arg); /** - * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelReestablish */ -void WarningMessage_free(struct LDKWarningMessage this_obj); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * Checks if two ChannelReestablishs 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. */ -const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; +bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ -void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The channel ID */ -struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); +const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The channel ID */ -void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new WarningMessage given each field + * The short channel ID */ -MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Creates a copy of the WarningMessage + * The short channel ID */ -struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two WarningMessages 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. + * A signature by the node key */ -bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); +struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + * A signature by the node key */ -void Ping_free(struct LDKPing this_obj); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The desired response length. + * A signature by the funding key */ -uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); +struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The desired response length. + * A signature by the funding key */ -void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The ping packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Constructs a new AnnouncementSignatures given each field */ -uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); /** - * The ping packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Creates a copy of the AnnouncementSignatures */ -void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); /** - * Constructs a new Ping given each field + * Checks if two AnnouncementSignaturess 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. */ -MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); /** - * Creates a copy of the Ping + * Frees any resources used by the NetAddress */ -struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +void NetAddress_free(struct LDKNetAddress this_ptr); /** - * Checks if two Pings 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. + * Creates a copy of the NetAddress */ -bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); +struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); /** - * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new IPv4-variant NetAddress */ -void Pong_free(struct LDKPong this_obj); +struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Utility method to constructs a new IPv6-variant NetAddress */ -uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); +struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Utility method to constructs a new OnionV2-variant NetAddress */ -void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a); /** - * Constructs a new Pong given each field + * Utility method to constructs a new OnionV3-variant NetAddress */ -MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); /** - * Creates a copy of the Pong + * Utility method to constructs a new Hostname-variant NetAddress */ -struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +struct LDKNetAddress NetAddress_hostname(struct LDKHostname hostname, uint16_t port); /** - * Checks if two Pongs contain equal inner contents. + * Checks if two NetAddresss 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. */ -bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); +bool NetAddress_eq(const struct LDKNetAddress *NONNULL_PTR a, const struct LDKNetAddress *NONNULL_PTR b); /** - * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + * Serialize the NetAddress object into a byte array which can be read by NetAddress_read */ -void OpenChannel_free(struct LDKOpenChannel this_obj); +struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); /** - * The genesis hash of the blockchain where the channel is to be opened + * Read a NetAddress from a byte array, created by NetAddress_write */ -const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain where the channel is to be opened + * Frees any resources used by the UnsignedGossipMessage */ -void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); /** - * A temporary channel ID, until the funding outpoint is announced + * Creates a copy of the UnsignedGossipMessage */ -const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); /** - * A temporary channel ID, until the funding outpoint is announced + * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage */ -void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); /** - * The channel value + * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage */ -uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); /** - * The channel value + * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage */ -void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read */ -uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The advertised features */ -uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The advertised features */ -void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * A strictly monotonic announcement counter, with gaps allowed */ -uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * A strictly monotonic announcement counter, with gaps allowed */ -void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * An RGB color for UI purposes */ -uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * An RGB color for UI purposes */ -void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * The feerate per 1000-weight of sender generated transactions, until updated by - * [`UpdateFee`] + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The feerate per 1000-weight of sender generated transactions, until updated by - * [`UpdateFee`] + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if - * they broadcast a commitment transaction + * List of addresses on which this node is reachable + * + * Returns a copy of the field. */ -uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKCVec_NetAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if - * they broadcast a commitment transaction + * List of addresses on which this node is reachable */ -void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); /** - * The maximum number of inbound HTLCs towards sender + * Creates a copy of the UnsignedNodeAnnouncement */ -uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); /** - * The maximum number of inbound HTLCs towards sender + * Checks if two UnsignedNodeAnnouncements 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. */ -void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); /** - * The sender's key controlling the funding transaction + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); /** - * The sender's key controlling the funding transaction + * The signature by the node key */ -void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The signature by the node key */ -struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The actual content of the announcement */ -void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * A payment key to sender for transactions broadcast by counterparty + * The actual content of the announcement */ -struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); /** - * A payment key to sender for transactions broadcast by counterparty + * Constructs a new NodeAnnouncement given each field */ -void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Creates a copy of the NodeAnnouncement */ -struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Checks if two NodeAnnouncements 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. */ -void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); /** - * Used to derive an HTLC payment key to sender + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** - * Used to derive an HTLC payment key to sender + * The advertised channel features */ -void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The advertised channel features */ -struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The genesis hash of the blockchain where the channel is to be opened */ -void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * The channel flags to be used + * The genesis hash of the blockchain where the channel is to be opened */ -uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The channel flags to be used + * The short channel ID */ -void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The short channel ID */ -struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * One of the two `node_id`s which are endpoints of this channel */ -void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Creates a copy of the OpenChannel + * One of the two `node_id`s which are endpoints of this channel */ -struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Checks if two OpenChannels 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. + * The other of the two `node_id`s which are endpoints of this channel */ -bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + * The other of the two `node_id`s which are endpoints of this channel */ -void AcceptChannel_free(struct LDKAcceptChannel this_obj); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * A temporary channel ID, until the funding outpoint is announced + * The funding key for the first node */ -const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * A temporary channel ID, until the funding outpoint is announced + * The funding key for the first node */ -void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The funding key for the second node */ -uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The funding key for the second node */ -void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Creates a copy of the UnsignedChannelAnnouncement */ -uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Checks if two UnsignedChannelAnnouncements 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. */ -void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Authentication of the announcement by the first public node */ -void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Authentication of the announcement by the first public node */ -uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Authentication of the announcement by the second public node */ -void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Minimum depth of the funding transaction before the channel is considered open + * Authentication of the announcement by the second public node */ -uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Minimum depth of the funding transaction before the channel is considered open + * Proof of funding UTXO ownership by the first public node */ -void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * Proof of funding UTXO ownership by the first public node */ -uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * Proof of funding UTXO ownership by the second public node */ -void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards sender + * Proof of funding UTXO ownership by the second public node */ -uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The maximum number of inbound HTLCs towards sender + * The actual announcement */ -void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The sender's key controlling the funding transaction + * The actual announcement */ -struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); /** - * The sender's key controlling the funding transaction + * Constructs a new ChannelAnnouncement given each field */ -void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Creates a copy of the ChannelAnnouncement */ -struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Checks if two ChannelAnnouncements 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. */ -void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); /** - * A payment key to sender for transactions broadcast by counterparty + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** - * A payment key to sender for transactions broadcast by counterparty + * The genesis hash of the blockchain where the channel is to be opened */ -void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; /** - * Used to derive a payment key to sender for transactions broadcast by sender + * The genesis hash of the blockchain where the channel is to be opened */ -struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * The short channel ID */ -void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * The short channel ID */ -struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * Channel flags */ -void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent. - * - * If this is `None`, we derive the channel type from the intersection of - * our feature bits with our counterparty's feature bits from the [`Init`] message. - * This is required to match the equivalent field in [`OpenChannel::channel_type`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Channel flags */ -struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The channel type that this channel will represent. - * - * If this is `None`, we derive the channel type from the intersection of - * our feature bits with our counterparty's feature bits from the [`Init`] message. - * This is required to match the equivalent field in [`OpenChannel::channel_type`]. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Creates a copy of the AcceptChannel + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); /** - * Checks if two AcceptChannels 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. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void FundingCreated_free(struct LDKFundingCreated this_obj); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * A temporary channel ID, until the funding is established + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * A temporary channel ID, until the funding is established + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * The funding transaction ID + * The base HTLC fee charged by sender, in milli-satoshi */ -const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The funding transaction ID + * The base HTLC fee charged by sender, in milli-satoshi */ -void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The specific output index funding this channel + * The amount to fee multiplier, in micro-satoshi */ -uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The specific output index funding this channel + * The amount to fee multiplier, in micro-satoshi */ -void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val); +void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Constructs a new FundingCreated given each field + * Constructs a new UnsignedChannelUpdate given each field */ -MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKSignature signature_arg); +MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); /** - * Creates a copy of the FundingCreated + * Creates a copy of the UnsignedChannelUpdate */ -struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); /** - * Checks if two FundingCreateds contain equal inner contents. + * Checks if two UnsignedChannelUpdates 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. */ -bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); +bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); /** - * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ -void FundingSigned_free(struct LDKFundingSigned this_obj); +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** - * The channel ID + * A signature of the channel update */ -const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; +struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * A signature of the channel update */ -void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The actual channel update */ -struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The actual channel update */ -void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); /** - * Constructs a new FundingSigned given each field + * Constructs a new ChannelUpdate given each field */ -MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg); +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); /** - * Creates a copy of the FundingSigned + * Creates a copy of the ChannelUpdate */ -struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); /** - * Checks if two FundingSigneds contain equal inner contents. + * Checks if two ChannelUpdates 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. */ -bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); +bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); /** - * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ -void ChannelReady_free(struct LDKChannelReady this_obj); +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** - * The channel ID + * The genesis hash of the blockchain being queried */ -const uint8_t (*ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr))[32]; +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The channel ID + * The genesis hash of the blockchain being queried */ -void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The per-commitment point of the second commitment transaction + * The height of the first block for the channel UTXOs being queried */ -struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); +uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * The per-commitment point of the second commitment transaction + * The height of the first block for the channel UTXOs being queried */ -void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * The number of blocks to include in the query results */ -struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); +uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * The number of blocks to include in the query results */ -void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new ChannelReady given each field + * Constructs a new QueryChannelRange given each field */ -MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); /** - * Creates a copy of the ChannelReady + * Creates a copy of the QueryChannelRange */ -struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); /** - * Checks if two ChannelReadys contain equal inner contents. + * Checks if two QueryChannelRanges 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. */ -bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); +bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); /** - * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ -void Shutdown_free(struct LDKShutdown this_obj); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** - * The channel ID + * The genesis hash of the blockchain being queried */ -const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The channel ID + * The genesis hash of the blockchain being queried */ -void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * The height of the first block in the range of the reply */ -struct LDKu8slice Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); +uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * The height of the first block in the range of the reply */ -void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new Shutdown given each field + * The number of blocks included in the range of the reply */ -MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Creates a copy of the Shutdown + * The number of blocks included in the range of the reply */ -struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if two Shutdowns 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. + * True when this is the final reply for a query */ -bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); +bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. + * True when this is the final reply for a query */ -void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); +void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * The `short_channel_id`s in the channel range + * + * Returns a copy of the field. */ -uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * The `short_channel_id`s in the channel range */ -void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Constructs a new ReplyChannelRange given each field */ -uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Creates a copy of the ReplyChannelRange */ -void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); /** - * Constructs a new ClosingSignedFeeRange given each field + * Checks if two ReplyChannelRanges 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. */ -MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); +bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); /** - * Creates a copy of the ClosingSignedFeeRange + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ -struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** - * Checks if two ClosingSignedFeeRanges 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. + * The genesis hash of the blockchain being queried */ -bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + * The genesis hash of the blockchain being queried */ -void ClosingSigned_free(struct LDKClosingSigned this_obj); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The channel ID + * The short_channel_ids that are being queried + * + * Returns a copy of the field. */ -const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); /** - * The channel ID + * The short_channel_ids that are being queried */ -void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The proposed total fee for the closing transaction + * Constructs a new QueryShortChannelIds given each field */ -uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The proposed total fee for the closing transaction + * Creates a copy of the QueryShortChannelIds */ -void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); /** - * A signature on the closing transaction + * Checks if two QueryShortChannelIdss 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. */ -struct LDKSignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); /** - * A signature on the closing transaction + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ -void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The genesis hash of the blockchain that was queried */ -struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The genesis hash of the blockchain that was queried */ -void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new ClosingSigned given each field + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKSignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); +bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); /** - * Creates a copy of the ClosingSigned + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); /** - * Checks if two ClosingSigneds 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. + * Constructs a new ReplyShortChannelIdsEnd given each field */ -bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); /** - * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. + * Creates a copy of the ReplyShortChannelIdsEnd */ -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); /** - * The channel ID + * Checks if two ReplyShortChannelIdsEnds 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. */ -const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); /** - * The channel ID + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ -void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); /** - * The HTLC ID + * The genesis hash of the blockchain for channel and node information */ -uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; /** - * The HTLC ID + * The genesis hash of the blockchain for channel and node information */ -void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The HTLC value in milli-satoshi + * The starting unix timestamp */ -uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The HTLC value in milli-satoshi + * The starting unix timestamp */ -void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The payment hash, the pre-image of which controls HTLC redemption + * The range of information in seconds */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The payment hash, the pre-image of which controls HTLC redemption + * The range of information in seconds */ -void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The expiry height of the HTLC + * Constructs a new GossipTimestampFilter given each field */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); /** - * The expiry height of the HTLC + * Creates a copy of the GossipTimestampFilter */ -void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); /** - * Creates a copy of the UpdateAddHTLC + * Checks if two GossipTimestampFilters 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. */ -struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); /** - * Checks if two UpdateAddHTLCs 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. + * Frees any resources used by the ErrorAction */ -bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); +void ErrorAction_free(struct LDKErrorAction this_ptr); /** - * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. + * Creates a copy of the ErrorAction */ -void OnionMessage_free(struct LDKOnionMessage this_obj); +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); /** - * Used in decrypting the onion packet's payload. + * Utility method to constructs a new DisconnectPeer-variant ErrorAction */ -struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); /** - * Used in decrypting the onion packet's payload. + * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction */ -void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKErrorAction ErrorAction_disconnect_peer_with_warning(struct LDKWarningMessage msg); /** - * Creates a copy of the OnionMessage + * Utility method to constructs a new IgnoreError-variant ErrorAction */ -struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); +struct LDKErrorAction ErrorAction_ignore_error(void); /** - * Checks if two OnionMessages 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. + * Utility method to constructs a new IgnoreAndLog-variant ErrorAction */ -bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); +struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); /** - * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction */ -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); +struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); /** - * The channel ID + * Utility method to constructs a new SendErrorMessage-variant ErrorAction */ -const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); /** - * The channel ID + * Utility method to constructs a new SendWarningMessage-variant ErrorAction */ -void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); /** - * The HTLC ID + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +void LightningError_free(struct LDKLightningError this_obj); /** - * The HTLC ID + * A human-readable message describing the error */ -void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * The pre-image of the payment hash, allowing HTLC redemption + * A human-readable message describing the error */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); /** - * The pre-image of the payment hash, allowing HTLC redemption + * The action which should be taken against the offending peer. */ -void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Constructs a new UpdateFulfillHTLC given each field + * The action which should be taken against the offending peer. */ -MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); /** - * Creates a copy of the UpdateFulfillHTLC + * Constructs a new LightningError given each field */ -struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); /** - * Checks if two UpdateFulfillHTLCs 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. + * Creates a copy of the LightningError */ -bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); +struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); /** - * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. */ -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** - * The channel ID + * `update_add_htlc` messages which should be sent */ -const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * `update_add_htlc` messages which should be sent */ -void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); /** - * The HTLC ID + * `update_fulfill_htlc` messages which should be sent */ -uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The HTLC ID + * `update_fulfill_htlc` messages which should be sent */ -void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); /** - * Creates a copy of the UpdateFailHTLC + * `update_fail_htlc` messages which should be sent */ -struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Checks if two UpdateFailHTLCs 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. + * `update_fail_htlc` messages which should be sent */ -bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); /** - * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + * `update_fail_malformed_htlc` messages which should be sent */ -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); +struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * `update_fail_malformed_htlc` messages which should be sent */ -const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); /** - * The channel ID + * An `update_fee` message which should be sent + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The HTLC ID + * An `update_fee` message which should be sent + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); /** - * The HTLC ID + * A `commitment_signed` message which should be sent */ -void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The failure code + * A `commitment_signed` message which should be sent */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); /** - * The failure code + * Constructs a new CommitmentUpdate given each field */ -void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); /** - * Creates a copy of the UpdateFailMalformedHTLC + * Creates a copy of the CommitmentUpdate */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); /** - * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. + * Checks if two CommitmentUpdates 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. */ -bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); +bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); /** - * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** - * The channel ID + * Calls the free function if one is set */ -const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); /** - * The channel ID + * Calls the free function if one is set */ -void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); /** - * A signature on the commitment transaction + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ -struct LDKSignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); /** - * A signature on the commitment transaction + * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ -void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); /** - * Signatures on the HTLC transactions - * - * Returns a copy of the field. + * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read */ -struct LDKCVec_SignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z AcceptChannelV2_write(const struct LDKAcceptChannelV2 *NONNULL_PTR obj); /** - * Signatures on the HTLC transactions + * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write */ -void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +struct LDKCResult_AcceptChannelV2DecodeErrorZ AcceptChannelV2_read(struct LDKu8slice ser); /** - * Constructs a new CommitmentSigned given each field + * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKSignature signature_arg, struct LDKCVec_SignatureZ htlc_signatures_arg); +struct LDKCVec_u8Z TxAddInput_write(const struct LDKTxAddInput *NONNULL_PTR obj); /** - * Creates a copy of the CommitmentSigned + * Read a TxAddInput from a byte array, created by TxAddInput_write */ -struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +struct LDKCResult_TxAddInputDecodeErrorZ TxAddInput_read(struct LDKu8slice ser); /** - * Checks if two CommitmentSigneds 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. + * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read */ -bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); +struct LDKCVec_u8Z TxAddOutput_write(const struct LDKTxAddOutput *NONNULL_PTR obj); /** - * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + * Read a TxAddOutput from a byte array, created by TxAddOutput_write */ -void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); +struct LDKCResult_TxAddOutputDecodeErrorZ TxAddOutput_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read */ -const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z TxRemoveInput_write(const struct LDKTxRemoveInput *NONNULL_PTR obj); /** - * The channel ID + * Read a TxRemoveInput from a byte array, created by TxRemoveInput_write */ -void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_TxRemoveInputDecodeErrorZ TxRemoveInput_read(struct LDKu8slice ser); /** - * The secret corresponding to the per-commitment point + * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z TxRemoveOutput_write(const struct LDKTxRemoveOutput *NONNULL_PTR obj); /** - * The secret corresponding to the per-commitment point + * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write */ -void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_TxRemoveOutputDecodeErrorZ TxRemoveOutput_read(struct LDKu8slice ser); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Serialize the TxComplete object into a byte array which can be read by TxComplete_read */ -struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxComplete_write(const struct LDKTxComplete *NONNULL_PTR obj); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Read a TxComplete from a byte array, created by TxComplete_write */ -void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_TxCompleteDecodeErrorZ TxComplete_read(struct LDKu8slice ser); /** - * Constructs a new RevokeAndACK given each field + * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read */ -MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +struct LDKCVec_u8Z TxSignatures_write(const struct LDKTxSignatures *NONNULL_PTR obj); /** - * Creates a copy of the RevokeAndACK + * Read a TxSignatures from a byte array, created by TxSignatures_write */ -struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +struct LDKCResult_TxSignaturesDecodeErrorZ TxSignatures_read(struct LDKu8slice ser); /** - * Checks if two RevokeAndACKs 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. + * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read */ -bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); +struct LDKCVec_u8Z TxInitRbf_write(const struct LDKTxInitRbf *NONNULL_PTR obj); /** - * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + * Read a TxInitRbf from a byte array, created by TxInitRbf_write */ -void UpdateFee_free(struct LDKUpdateFee this_obj); +struct LDKCResult_TxInitRbfDecodeErrorZ TxInitRbf_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read */ -const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z TxAckRbf_write(const struct LDKTxAckRbf *NONNULL_PTR obj); /** - * The channel ID + * Read a TxAckRbf from a byte array, created by TxAckRbf_write */ -void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_TxAckRbfDecodeErrorZ TxAckRbf_read(struct LDKu8slice ser); /** - * Fee rate per 1000-weight of the transaction + * Serialize the TxAbort object into a byte array which can be read by TxAbort_read */ -uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxAbort_write(const struct LDKTxAbort *NONNULL_PTR obj); /** - * Fee rate per 1000-weight of the transaction + * Read a TxAbort from a byte array, created by TxAbort_write */ -void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_TxAbortDecodeErrorZ TxAbort_read(struct LDKu8slice ser); /** - * Constructs a new UpdateFee given each field + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read */ -MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); /** - * Creates a copy of the UpdateFee + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write */ -struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); /** - * Checks if two UpdateFees 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. + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ -bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); +struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); /** - * Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ -void DataLossProtect_free(struct LDKDataLossProtect this_obj); +struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ -const uint8_t (*DataLossProtect_get_your_last_per_commitment_secret(const struct LDKDataLossProtect *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ -void DataLossProtect_set_your_last_per_commitment_secret(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); /** - * The sender's per-commitment point for their current commitment transaction + * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read */ -struct LDKPublicKey DataLossProtect_get_my_current_per_commitment_point(const struct LDKDataLossProtect *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); /** - * The sender's per-commitment point for their current commitment transaction + * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write */ -void DataLossProtect_set_my_current_per_commitment_point(struct LDKDataLossProtect *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); /** - * Constructs a new DataLossProtect given each field + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ -MUST_USE_RES struct LDKDataLossProtect DataLossProtect_new(struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg); +struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); /** - * Creates a copy of the DataLossProtect + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write */ -struct LDKDataLossProtect DataLossProtect_clone(const struct LDKDataLossProtect *NONNULL_PTR orig); +struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); /** - * Checks if two DataLossProtects 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. + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read */ -bool DataLossProtect_eq(const struct LDKDataLossProtect *NONNULL_PTR a, const struct LDKDataLossProtect *NONNULL_PTR b); +struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); /** - * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + * Read a FundingCreated from a byte array, created by FundingCreated_write */ -void ChannelReestablish_free(struct LDKChannelReestablish this_obj); +struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read */ -const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); /** - * The channel ID + * Read a FundingSigned from a byte array, created by FundingSigned_write */ -void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); /** - * The next commitment number for the sender + * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); /** - * The next commitment number for the sender + * Read a ChannelReady from a byte array, created by ChannelReady_write */ -void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); /** - * The next commitment number for the recipient + * Serialize the Init object into a byte array which can be read by Init_read */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); /** - * The next commitment number for the recipient + * Read a Init from a byte array, created by Init_write */ -void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelReestablish + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read */ -struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); /** - * Checks if two ChannelReestablishs 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. + * Read a OpenChannel from a byte array, created by OpenChannel_write */ -bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); +struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); /** - * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read */ -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); +struct LDKCVec_u8Z OpenChannelV2_write(const struct LDKOpenChannelV2 *NONNULL_PTR obj); /** - * The channel ID + * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write */ -const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_OpenChannelV2DecodeErrorZ OpenChannelV2_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read */ -void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); /** - * The short channel ID + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write */ -uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); /** - * The short channel ID + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read */ -void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); /** - * A signature by the node key + * Read a Shutdown from a byte array, created by Shutdown_write */ -struct LDKSignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); /** - * A signature by the node key + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read */ -void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); /** - * A signature by the funding key + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write */ -struct LDKSignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); /** - * A signature by the funding key + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read */ -void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); /** - * Constructs a new AnnouncementSignatures given each field + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write */ -MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKSignature node_signature_arg, struct LDKSignature bitcoin_signature_arg); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); /** - * Creates a copy of the AnnouncementSignatures + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read */ -struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); /** - * Checks if two AnnouncementSignaturess 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. + * Read a UpdateFee from a byte array, created by UpdateFee_write */ -bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); +struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); /** - * Frees any resources used by the NetAddress + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read */ -void NetAddress_free(struct LDKNetAddress this_ptr); +struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); /** - * Creates a copy of the NetAddress + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write */ -struct LDKNetAddress NetAddress_clone(const struct LDKNetAddress *NONNULL_PTR orig); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); /** - * Utility method to constructs a new IPv4-variant NetAddress + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read */ -struct LDKNetAddress NetAddress_ipv4(struct LDKFourBytes addr, uint16_t port); +struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); /** - * Utility method to constructs a new IPv6-variant NetAddress + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write */ -struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); /** - * Utility method to constructs a new OnionV2-variant NetAddress + * Read a OnionMessage from a byte array, created by OnionMessage_write */ -struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a); +struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); /** - * Utility method to constructs a new OnionV3-variant NetAddress + * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read */ -struct LDKNetAddress NetAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); +struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); /** - * Utility method to constructs a new Hostname-variant NetAddress + * Serialize the Ping object into a byte array which can be read by Ping_read */ -struct LDKNetAddress NetAddress_hostname(struct LDKHostname hostname, uint16_t port); +struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); /** - * Checks if two NetAddresss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Read a Ping from a byte array, created by Ping_write */ -bool NetAddress_eq(const struct LDKNetAddress *NONNULL_PTR a, const struct LDKNetAddress *NONNULL_PTR b); +struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); /** - * Serialize the NetAddress object into a byte array which can be read by NetAddress_read + * Serialize the Pong object into a byte array which can be read by Pong_read */ -struct LDKCVec_u8Z NetAddress_write(const struct LDKNetAddress *NONNULL_PTR obj); +struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); /** - * Read a NetAddress from a byte array, created by NetAddress_write + * Read a Pong from a byte array, created by Pong_write */ -struct LDKCResult_NetAddressDecodeErrorZ NetAddress_read(struct LDKu8slice ser); +struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); /** - * Frees any resources used by the UnsignedGossipMessage + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read */ -void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); /** - * Creates a copy of the UnsignedGossipMessage + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); /** - * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); +struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); /** - * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); /** - * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); +struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); /** - * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ -struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); /** - * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read */ -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); +struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); /** - * The advertised features + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write */ -struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); /** - * The advertised features + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read */ -void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); /** - * A strictly monotonic announcement counter, with gaps allowed + * Read a ErrorMessage from a byte array, created by ErrorMessage_write */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); /** - * A strictly monotonic announcement counter, with gaps allowed + * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read */ -void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * Read a WarningMessage from a byte array, created by WarningMessage_write */ -struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ -void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); /** - * An RGB color for UI purposes + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); /** - * An RGB color for UI purposes + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read */ -void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); /** - * An alias, for UI purposes. - * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write */ -struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); /** - * An alias, for UI purposes. - * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); /** - * List of addresses on which this node is reachable - * - * Returns a copy of the field. + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read */ -struct LDKCVec_NetAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); /** - * List of addresses on which this node is reachable + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read */ -void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); +struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); /** - * Creates a copy of the UnsignedNodeAnnouncement + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ -struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); /** - * Checks if two UnsignedNodeAnnouncements 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. + * Calculates the overflow safe ending block height for the query. + * + * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. */ -bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); /** - * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read */ -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); +struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); /** - * The signature by the node key + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ -struct LDKSignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); /** - * The signature by the node key + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ -void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); /** - * The actual content of the announcement + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ -struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); /** - * The actual content of the announcement + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read */ -void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); /** - * Constructs a new NodeAnnouncement given each field + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKSignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); /** - * Creates a copy of the NodeAnnouncement + * Calls the free function if one is set */ -struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); /** - * Checks if two NodeAnnouncements 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. + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. */ -bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); /** - * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Constructs a new IgnoringMessageHandler given each field */ -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); +MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); /** - * The advertised channel features + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The advertised channel features + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain where the channel is to be opened + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; +struct LDKOnionMessageProvider IgnoringMessageHandler_as_OnionMessageProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain where the channel is to be opened + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The short channel ID + * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The short channel ID + * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is */ -void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * One of the two `node_id`s which are endpoints of this channel + * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * One of the two `node_id`s which are endpoints of this channel + * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is */ -void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The other of the two `node_id`s which are endpoints of this channel + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** - * The other of the two `node_id`s which are endpoints of this channel + * Constructs a new ErroringMessageHandler */ -void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); /** - * The funding key for the first node + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * The funding key for the first node + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * The funding key for the second node + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void MessageHandler_free(struct LDKMessageHandler this_obj); /** - * The funding key for the second node + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Creates a copy of the UnsignedChannelAnnouncement + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); /** - * Checks if two UnsignedChannelAnnouncements 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. + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); +void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); /** - * Authentication of the announcement by the first public node + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::OnionMessenger */ -struct LDKSignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Authentication of the announcement by the first public node + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::OnionMessenger */ -void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); /** - * Authentication of the announcement by the second public node + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -struct LDKSignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +const struct LDKCustomMessageHandler *MessageHandler_get_custom_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Authentication of the announcement by the second public node + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +void MessageHandler_set_custom_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKCustomMessageHandler val); /** - * Proof of funding UTXO ownership by the first public node + * Constructs a new MessageHandler given each field */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg, struct LDKCustomMessageHandler custom_message_handler_arg); /** - * Proof of funding UTXO ownership by the first public node + * Creates a copy of a SocketDescriptor */ -void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** - * Proof of funding UTXO ownership by the second public node + * Calls the free function if one is set */ -struct LDKSignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); /** - * Proof of funding UTXO ownership by the second public node + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. */ -void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKSignature val); +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** - * The actual announcement + * Constructs a new PeerHandleError given each field */ -struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); /** - * The actual announcement + * Creates a copy of the PeerHandleError */ -void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); /** - * Constructs a new ChannelAnnouncement given each field + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKSignature node_signature_1_arg, struct LDKSignature node_signature_2_arg, struct LDKSignature bitcoin_signature_1_arg, struct LDKSignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +void PeerManager_free(struct LDKPeerManager this_obj); /** - * Creates a copy of the ChannelAnnouncement + * Constructs a new `PeerManager` with the given message handlers. + * + * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be + * cryptographically secure random bytes. + * + * `current_time` is used as an always-increasing counter that survives across restarts and is + * incremented irregularly internally. In general it is best to simply use the current UNIX + * timestamp, however if it is not available a persistent counter that increases once per + * minute should suffice. */ -struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKNodeSigner node_signer); /** - * Checks if two ChannelAnnouncements 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. + * Get a list of tuples mapping from node id to network addresses for peers which have + * completed the initial handshake. + * + * For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter + * passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial + * handshake has completed and we are sure the remote peer has the private key for the given + * [`PublicKey`]. + * + * The returned `Option`s will only be `Some` if an address had been previously given via + * [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`]. */ -bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); +MUST_USE_RES struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + * Indicates a new outbound connection has been established to a node with the given `node_id` + * and an optional remote network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * If an `Err` is returned here you must disconnect the connection immediately. + * + * Returns a small number of bytes to send to the remote node (currently always 50). + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); +MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); /** - * The genesis hash of the blockchain where the channel is to be opened + * Indicates a new inbound connection has been established to a node with an optional remote + * network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * May refuse the connection by returning an Err, but will never write bytes to the remote end + * (outbound connector always speaks first). If an `Err` is returned here you must disconnect + * the connection immediately. + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); /** - * The genesis hash of the blockchain where the channel is to be opened + * Indicates that there is room to write data to the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before + * returning. Thus, be very careful with reentrancy issues! The invariants around calling + * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be + * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't + * sufficient! + * + * [`send_data`]: SocketDescriptor::send_data + * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail */ -void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * The short channel ID + * Indicates that data was read from the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. + * Thus, however, you should call [`process_events`] after any `read_event` to generate + * [`send_data`] calls to handle responses. + * + * If `Ok(true)` is returned, further read_events should not be triggered until a + * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the + * send buffer). + * + * In order to avoid processing too many messages at once per peer, `data` should be on the + * order of 4KiB. + * + * [`send_data`]: SocketDescriptor::send_data + * [`process_events`]: PeerManager::process_events */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); /** - * The short channel ID + * Checks for any events generated by our handlers and processes them. Includes sending most + * response messages as well as messages generated by calls to handler functions directly (eg + * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * + * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] + * or one of the other clients provided in our language bindings. + * + * Note that if there are any other calls to this function waiting on lock(s) this may return + * without doing any work. All available events that need handling will be handled before the + * other calls return. + * + * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * [`send_data`]: SocketDescriptor::send_data */ -void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Indicates that the given socket descriptor's connection is now closed. */ -uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Disconnect a peer given its node id. + * + * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the + * peer. Thus, be very careful about reentrancy issues. + * + * [`disconnect_socket`]: SocketDescriptor::disconnect_socket */ -void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * Channel flags + * 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. */ -uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Channel flags + * Send pings to each peer and disconnect those which did not respond to the last round of + * pings. + * + * This may be called on any timescale you want, however, roughly once every ten seconds is + * preferred. The call rate determines both how often we send a ping to our peers and how much + * time they have to respond before we disconnect them. + * + * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * [`send_data`]: SocketDescriptor::send_data */ -void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Generates a signed node_announcement from the given arguments, sending it to all connected + * peers. Note that peers will likely ignore this message unless we have at least one public + * channel which has at least six confirmations on-chain. + * + * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this + * node to humans. They carry no in-protocol meaning. + * + * `addresses` represent the set (possibly empty) of socket addresses on which this node + * accepts incoming connections. These will be included in the node_announcement, publicly + * tying these addresses together and to this node. If you wish to preserve user privacy, + * addresses should likely contain only Tor Onion addresses. + * + * Panics if `addresses` is absurdly large (more than 100). + * + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Gets the weight for an HTLC-Success transaction. */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); +uint64_t htlc_success_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Gets the weight for an HTLC-Timeout transaction. */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +uint64_t htlc_timeout_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Creates a copy of the HTLCClaim */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); /** - * The maximum HTLC value incoming to sender, in milli-satoshi. - * - * This used to be optional. + * Utility method to constructs a new OfferedTimeout-variant HTLCClaim */ -uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +enum LDKHTLCClaim HTLCClaim_offered_timeout(void); /** - * The maximum HTLC value incoming to sender, in milli-satoshi. - * - * This used to be optional. + * Utility method to constructs a new OfferedPreimage-variant HTLCClaim */ -void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +enum LDKHTLCClaim HTLCClaim_offered_preimage(void); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim */ -void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); /** - * The amount to fee multiplier, in micro-satoshi + * Utility method to constructs a new Revocation-variant HTLCClaim */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +enum LDKHTLCClaim HTLCClaim_revocation(void); /** - * The amount to fee multiplier, in micro-satoshi + * Checks if two HTLCClaims contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Check if a given input witness attempts to claim a HTLC. */ -struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Build the commitment secret from the seed and the commitment number */ -void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** - * Constructs a new UnsignedChannelUpdate given each field + * Build a closing transaction */ -MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); +struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); /** - * Creates a copy of the UnsignedChannelUpdate + * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. */ -struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); /** - * Checks if two UnsignedChannelUpdates 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. + * Creates a copy of the CounterpartyCommitmentSecrets */ -bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); +struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + * Creates a new empty `CounterpartyCommitmentSecrets` structure. */ -void ChannelUpdate_free(struct LDKChannelUpdate this_obj); +MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); /** - * A signature of the channel update + * Returns the minimum index of all stored secrets. Note that indexes start + * at 1 << 48 and get decremented by one for each new secret. */ -struct LDKSignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); /** - * A signature of the channel update + * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret + * was generated in accordance with BOLT 3 and is consistent with previous secrets. */ -void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKSignature val); +MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); /** - * The actual channel update + * Returns the secret at `idx`. + * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); /** - * The actual channel update + * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read */ -void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); /** - * Constructs a new ChannelUpdate given each field + * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write */ -MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKSignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); /** - * Creates a copy of the ChannelUpdate + * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) + * from the base secret and the per_commitment_point. */ -struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** - * Checks if two ChannelUpdates 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. + * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) + * from the base point and the per_commitment_key. This is the public equivalent of + * derive_private_key - using only public keys to derive a public key instead of private keys. */ -bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); +struct LDKPublicKey derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); /** - * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + * Derives a per-commitment-transaction revocation key from its constituent parts. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. */ -void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); +struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** - * The genesis hash of the blockchain being queried + * Derives a per-commitment-transaction revocation public key from its constituent parts. This is + * the public equivalend of derive_private_revocation_key - using only public keys to derive a + * public key instead of private keys. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_point always come from cheater + * and revocation_base_point always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. + * + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). */ -const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); /** - * The genesis hash of the blockchain being queried + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. */ -void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** - * The height of the first block for the channel UTXOs being queried + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The height of the first block for the channel UTXOs being queried + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The number of blocks to include in the query results + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The number of blocks to include in the query results + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new QueryChannelRange given each field + * Broadcaster's HTLC Key */ -MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Creates a copy of the QueryChannelRange + * Broadcaster's HTLC Key */ -struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if two QueryChannelRanges 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. + * Countersignatory's HTLC Key */ -bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); +struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + * Countersignatory's HTLC Key */ -void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The genesis hash of the blockchain being queried + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain being queried + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The height of the first block in the range of the reply + * Constructs a new TxCreationKeys given each field */ -uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); /** - * The height of the first block in the range of the reply + * Checks if two TxCreationKeyss 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. */ -void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); /** - * The number of blocks included in the range of the reply + * Creates a copy of the TxCreationKeys */ -uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); /** - * The number of blocks included in the range of the reply + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read */ -void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); /** - * True when this is the final reply for a query + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write */ -bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); /** - * True when this is the final reply for a query + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. */ -void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** - * The `short_channel_id`s in the channel range - * - * Returns a copy of the field. + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The `short_channel_id`s in the channel range + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ReplyChannelRange given each field + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Creates a copy of the ReplyChannelRange + * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if two ReplyChannelRanges 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. + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The genesis hash of the blockchain being queried + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain being queried + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The short_channel_ids that are being queried - * - * Returns a copy of the field. + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); +struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The short_channel_ids that are being queried + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new QueryShortChannelIds given each field + * Constructs a new ChannelPublicKeys given each field */ -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); /** - * Creates a copy of the QueryShortChannelIds + * Creates a copy of the ChannelPublicKeys */ -struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); /** - * Checks if two QueryShortChannelIdss contain equal inner contents. + * Checks if two ChannelPublicKeyss 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. */ -bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); +bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); /** - * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); +struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); /** - * The genesis hash of the blockchain that was queried + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain that was queried + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * A script either spendable by the revocation + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); /** - * Constructs a new ReplyShortChannelIdsEnd given each field + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** - * Creates a copy of the ReplyShortChannelIdsEnd + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. + */ +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); + +/** + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); /** - * Checks if two ReplyShortChannelIdsEnds 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. + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); /** - * The genesis hash of the blockchain for channel and node information + * The CLTV lock-time at which this HTLC expires. */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain for channel and node information + * The CLTV lock-time at which this HTLC expires. */ -void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); /** - * The starting unix timestamp + * The hash of the preimage which unlocks this HTLC. */ -uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; /** - * The starting unix timestamp + * The hash of the preimage which unlocks this HTLC. */ -void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The range of information in seconds + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * The range of information in seconds + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * Constructs a new GossipTimestampFilter given each field + * Constructs a new HTLCOutputInCommitment given each field */ -MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); /** - * Creates a copy of the GossipTimestampFilter + * Creates a copy of the HTLCOutputInCommitment */ -struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); /** - * Checks if two GossipTimestampFilters contain equal inner contents. + * Checks if two HTLCOutputInCommitments 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. */ -bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); - -/** - * Frees any resources used by the ErrorAction - */ -void ErrorAction_free(struct LDKErrorAction this_ptr); +bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); /** - * Creates a copy of the ErrorAction + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ -struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); +struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); /** - * Utility method to constructs a new DisconnectPeer-variant ErrorAction + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write */ -struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** - * Utility method to constructs a new IgnoreError-variant ErrorAction + * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc + * does not need to have its previous_output_index filled. */ -struct LDKErrorAction ErrorAction_ignore_error(void); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** - * Utility method to constructs a new IgnoreAndLog-variant ErrorAction + * Gets the redeemscript for a funding output from the two funding public keys. + * Note that the order of funding public keys does not matter. */ -struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); +struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC + * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the + * transaction which needs signing, and can be used to construct an HTLC transaction which is + * broadcastable given a counterparty HTLC signature. + * + * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the + * commitment transaction). */ -struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); +struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); /** - * Utility method to constructs a new SendErrorMessage-variant ErrorAction + * Returns the witness required to satisfy and spend a HTLC input. */ -struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); +struct LDKWitness build_htlc_input_witness(struct LDKSignature local_sig, struct LDKSignature remote_sig, struct LDKCOption_PaymentPreimageZ preimage, struct LDKu8slice redeem_script, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * Utility method to constructs a new SendWarningMessage-variant ErrorAction + * Gets the witnessScript for the to_remote output when anchors are enabled. */ -struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); +struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); /** - * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + * Gets the witnessScript for an anchor output from the funding public key. + * The witness in the spending input must be: + * + * After 16 blocks of confirmation, an alternative satisfying witness could be: + * <> + * (empty vector required to satisfy compliance with MINIMALIF-standard rule) */ -void LightningError_free(struct LDKLightningError this_obj); +struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); /** - * A human-readable message describing the error + * Returns the witness required to satisfy and spend an anchor input. */ -struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKSignature funding_sig); /** - * A human-readable message describing the error + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** - * The action which should be taken against the offending peer. + * Holder public keys */ -struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The action which should be taken against the offending peer. + * Holder public keys */ -void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Constructs a new LightningError given each field + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the LightningError + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * `update_add_htlc` messages which should be sent + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); /** - * `update_add_htlc` messages which should be sent + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * `update_fulfill_htlc` messages which should be sent + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); /** - * `update_fulfill_htlc` messages which should be sent + * The late-bound funding outpoint + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * `update_fail_htlc` messages which should be sent + * The late-bound funding outpoint + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * `update_fail_htlc` messages which should be sent + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); +struct LDKChannelTypeFeatures ChannelTransactionParameters_get_channel_type_features(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * `update_fail_malformed_htlc` messages which should be sent + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_channel_type_features(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * `update_fail_malformed_htlc` messages which should be sent + * Constructs a new ChannelTransactionParameters given each field */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKChannelTypeFeatures channel_type_features_arg); /** - * An `update_fee` message which should be sent - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelTransactionParameters */ -struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); /** - * An `update_fee` message which should be sent - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two ChannelTransactionParameterss 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. */ -void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); +bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); /** - * A `commitment_signed` message which should be sent + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** - * A `commitment_signed` message which should be sent + * Counter-party public keys */ -void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Constructs a new CommitmentUpdate given each field + * Counter-party public keys */ -MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Creates a copy of the CommitmentUpdate + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Checks if two CommitmentUpdates 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. + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Calls the free function if one is set + * Constructs a new CounterpartyChannelTransactionParameters given each field */ -void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * Calls the free function if one is set + * Creates a copy of the CounterpartyChannelTransactionParameters */ -void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Checks if two CounterpartyChannelTransactionParameterss 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. */ -void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); +bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); /** - * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + * Whether the late bound parameters are populated. */ -struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a AcceptChannel from a byte array, created by AcceptChannel_write + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); /** - * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write */ -struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read */ -struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); /** - * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write */ -struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Read a ClosingSigned from a byte array, created by ClosingSigned_write + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** - * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read + * Get the channel pubkeys for the broadcaster */ -struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write + * Get the channel pubkeys for the countersignatory */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + * Whether the channel is outbound from the broadcaster. + * + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + * The funding outpoint */ -struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Read a FundingCreated from a byte array, created by FundingCreated_write + * Whether to use anchors for this channel */ -struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelTypeFeatures DirectedChannelTransactionParameters_channel_type_features(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); /** - * Read a FundingSigned from a byte array, created by FundingSigned_write + * Our counterparty's signature for the transaction */ -struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read + * Our counterparty's signature for the transaction */ -struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); /** - * Read a ChannelReady from a byte array, created by ChannelReady_write + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * + * Returns a copy of the field. */ -struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); +struct LDKCVec_SignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Serialize the Init object into a byte array which can be read by Init_read + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ -struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); /** - * Read a Init from a byte array, created by Init_write + * Creates a copy of the HolderCommitmentTransaction */ -struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); /** - * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read */ -struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); /** - * Read a OpenChannel from a byte array, created by OpenChannel_write + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write */ -struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** - * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. */ -struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); /** - * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** - * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + * The commitment transaction */ -struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); /** - * Read a Shutdown from a byte array, created by Shutdown_write + * The commitment transaction */ -struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); /** - * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; /** - * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + * The txid for the commitment transaction. + * + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + * Constructs a new BuiltCommitmentTransaction given each field */ -struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); /** - * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + * Creates a copy of the BuiltCommitmentTransaction */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); /** - * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read */ -struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); /** - * Read a UpdateFee from a byte array, created by UpdateFee_write + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write */ -struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** - * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + * Signs the counterparty's commitment transaction. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + * Signs the holder commitment transaction because we are about to broadcast it. */ -struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +void ClosingTransaction_free(struct LDKClosingTransaction this_obj); /** - * Read a OnionMessage from a byte array, created by OnionMessage_write + * Creates a copy of the ClosingTransaction */ -struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); +struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); /** - * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read + * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. */ -struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); +uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); /** - * Serialize the Ping object into a byte array which can be read by Ping_read + * Checks if two ClosingTransactions 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. */ -struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); +bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); /** - * Read a Ping from a byte array, created by Ping_write + * Construct an object of the class */ -struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +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); /** - * Serialize the Pong object into a byte array which can be read by Pong_read + * Trust our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Read a Pong from a byte array, created by Pong_write + * Verify our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); /** - * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + * The value to be sent to the holder, or zero if the output will be omitted */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + * The value to be sent to the counterparty, or zero if the output will be omitted */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + * The destination of the holder's output */ -struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + * The destination of the counterparty's output */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); /** - * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + * The pre-built Bitcoin commitment transaction */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); /** - * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. */ -struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); /** - * Read a ErrorMessage from a byte array, created by ErrorMessage_write + * Creates a copy of the CommitmentTransaction */ -struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); /** - * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read */ -struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); +struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); /** - * Read a WarningMessage from a byte array, created by WarningMessage_write + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write */ -struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** - * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + * The backwards-counting commitment number */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + * The value to be sent to the broadcaster */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + * The value to be sent to the counterparty */ -struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + * Trust our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** - * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + * The transaction ID of the built Bitcoin transaction */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Calculates the overflow safe ending block height for the query. - * - * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. + * The pre-built Bitcoin commitment transaction */ -MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + * The pre-calculated transaction creation public keys. */ -struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + * Should anchors be used. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelTypeFeatures TrustedCommitmentTransaction_channel_type_features(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + * Get a signature for each HTLC which was included in the commitment transaction (ie for + * which HTLCOutputInCommitment::transaction_output_index.is_some()). + * + * The returned Vec has one entry for each HTLC, and in the same order. + * + * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a + * shared secret first. This prevents on-chain observers from discovering how many commitment + * transactions occurred in a channel before it was closed. + * + * This function gets the shared secret from relevant channel public keys and can be used to + * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. */ -struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + * Checks if two InitFeaturess 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. */ -struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); +bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); /** - * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + * Checks if two NodeFeaturess 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. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); /** - * Calls the free function if one is set + * Checks if two ChannelFeaturess 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. */ -void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); +bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); /** - * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + * Checks if two Bolt11InvoiceFeaturess 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. */ -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); /** - * Constructs a new IgnoringMessageHandler given each field + * Checks if two OfferFeaturess 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. */ -MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Checks if two InvoiceRequestFeaturess 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. */ -struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Checks if two Bolt12InvoiceFeaturess 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. */ -struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); /** - * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is + * Checks if two BlindedHopFeaturess 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. */ -struct LDKOnionMessageProvider IgnoringMessageHandler_as_OnionMessageProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); /** - * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + * Checks if two ChannelTypeFeaturess 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. */ -struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); /** - * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is + * Creates a copy of the InitFeatures */ -struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is + * Creates a copy of the NodeFeatures */ -struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is + * Creates a copy of the ChannelFeatures */ -struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + * Creates a copy of the Bolt11InvoiceFeatures */ -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); +struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); /** - * Constructs a new ErroringMessageHandler + * Creates a copy of the OfferFeatures */ -MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Creates a copy of the InvoiceRequestFeatures */ -struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * Creates a copy of the Bolt12InvoiceFeatures */ -struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); /** - * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + * Creates a copy of the BlindedHopFeatures */ -void MessageHandler_free(struct LDKMessageHandler this_obj); +struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Creates a copy of the ChannelTypeFeatures */ -const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. - * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. - * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * A message handler which handles onion messages. For now, this can only be an - * [`IgnoringMessageHandler`]. + * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); /** - * A message handler which handles onion messages. For now, this can only be an - * [`IgnoringMessageHandler`]. + * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. */ -void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); +void OfferFeatures_free(struct LDKOfferFeatures this_obj); /** - * Constructs a new MessageHandler given each field + * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg); +void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); /** - * Creates a copy of a SocketDescriptor + * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); +void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); /** - * Calls the free function if one is set + * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. */ -void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); +void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); /** - * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. */ -void PeerHandleError_free(struct LDKPeerHandleError this_obj); +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); /** - * Constructs a new PeerHandleError given each field + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Creates a copy of the PeerHandleError + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void PeerManager_free(struct LDKPeerManager this_obj); +MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new `PeerManager` with the given message handlers. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be - * cryptographically secure random bytes. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * `current_time` is used as an always-increasing counter that survives across restarts and is - * incremented irregularly internally. In general it is best to simply use the current UNIX - * timestamp, however if it is not available a persistent counter that increases once per - * minute should suffice. + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler, struct LDKNodeSigner node_signer); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Get a list of tuples mapping from node id to network addresses for peers which have - * completed the initial handshake. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter - * passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial - * handshake has completed and we are sure the remote peer has the private key for the given - * [`PublicKey`]. + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). * - * The returned `Option`s will only be `Some` if an address had been previously given via - * [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`]. + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Indicates a new outbound connection has been established to a node with the given `node_id` - * and an optional remote network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. - * - * If an `Err` is returned here you must disconnect the connection immediately. - * - * Returns a small number of bytes to send to the remote node (currently always 50). - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. - * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * Indicates a new inbound connection has been established to a node with an optional remote - * network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. - * - * May refuse the connection by returning an Err, but will never write bytes to the remote end - * (outbound connector always speaks first). If an `Err` is returned here you must disconnect - * the connection immediately. - * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. - * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * Returns true if this `Features` object contains required features unknown by `other`. */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * Indicates that there is room to write data to the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before - * returning. Thus, be very careful with reentrancy issues! The invariants around calling - * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be - * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't - * sufficient! - * - * [`send_data`]: SocketDescriptor::send_data - * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Indicates that data was read from the given socket descriptor. - * - * May return an Err to indicate that the connection should be closed. - * - * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. - * Thus, however, you should call [`process_events`] after any `read_event` to generate - * [`send_data`] calls to handle responses. - * - * If `Ok(true)` is returned, further read_events should not be triggered until a - * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the - * send buffer). + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * In order to avoid processing too many messages at once per peer, `data` should be on the - * order of 4KiB. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * [`send_data`]: SocketDescriptor::send_data - * [`process_events`]: PeerManager::process_events + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Checks for any events generated by our handlers and processes them. Includes sending most - * response messages as well as messages generated by calls to handler functions directly (eg - * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). - * - * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] - * or one of the other clients provided in our language bindings. - * - * Note that if there are any other calls to this function waiting on lock(s) this may return - * without doing any work. All available events that need handling will be handled before the - * other calls return. + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). * - * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - * [`send_data`]: SocketDescriptor::send_data + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Indicates that the given socket descriptor's connection is now closed. + * Create a blank Features with no features set */ -void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Disconnect a peer given its node id. - * - * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the - * peer. Thus, be very careful about reentrancy issues. - * - * [`disconnect_socket`]: SocketDescriptor::disconnect_socket + * Returns true if this `Features` object contains required features unknown by `other`. */ -void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * 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. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Send pings to each peer and disconnect those which did not respond to the last round of - * pings. - * - * This may be called on any timescale you want, however, roughly once every ten seconds is - * preferred. The call rate determines both how often we send a ping to our peers and how much - * time they have to respond before we disconnect them. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * [`send_data`]: SocketDescriptor::send_data + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a signed node_announcement from the given arguments, sending it to all connected - * peers. Note that peers will likely ignore this message unless we have at least one public - * channel which has at least six confirmations on-chain. - * - * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this - * node to humans. They carry no in-protocol meaning. - * - * `addresses` represent the set (possibly empty) of socket addresses on which this node - * accepts incoming connections. These will be included in the node_announcement, publicly - * tying these addresses together and to this node. If you wish to preserve user privacy, - * addresses should likely contain only Tor Onion addresses. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * Panics if `addresses` is absurdly large (more than 100). + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). * - * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_NetAddressZ addresses); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Gets the weight for an HTLC-Success transaction. + * Create a blank Features with no features set */ -uint64_t htlc_success_tx_weight(bool opt_anchors); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); /** - * Gets the weight for an HTLC-Timeout transaction. + * Returns true if this `Features` object contains required features unknown by `other`. */ -uint64_t htlc_timeout_tx_weight(bool opt_anchors); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * Creates a copy of the HTLCClaim + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OfferedTimeout-variant HTLCClaim + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -enum LDKHTLCClaim HTLCClaim_offered_timeout(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new OfferedPreimage-variant HTLCClaim + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -enum LDKHTLCClaim HTLCClaim_offered_preimage(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim + * Create a blank Features with no features set */ -enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); +MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); /** - * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim + * Returns true if this `Features` object contains required features unknown by `other`. */ -enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Revocation-variant HTLCClaim + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -enum LDKHTLCClaim HTLCClaim_revocation(void); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Checks if two HTLCClaims contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Check if a given input witness attempts to claim a HTLC. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Build the commitment secret from the seed and the commitment number + * Create a blank Features with no features set */ -struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); /** - * Build a closing transaction + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CounterpartyCommitmentSecrets + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a new empty `CounterpartyCommitmentSecrets` structure. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Returns the minimum index of all stored secrets. Note that indexes start - * at 1 << 48 and get decremented by one for each new secret. + * Create a blank Features with no features set */ -MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); /** - * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret - * was generated in accordance with BOLT 3 and is consistent with previous secrets. + * Returns true if this `Features` object contains required features unknown by `other`. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Returns the secret at `idx`. - * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) - * from the base secret and the per_commitment_point. + * Create a blank Features with no features set */ -struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); /** - * Derives a per-commitment-transaction public key (eg an htlc key or a delayed_payment key) - * from the base point and the per_commitment_key. This is the public equivalent of - * derive_private_key - using only public keys to derive a public key instead of private keys. + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKPublicKey derive_public_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey base_point); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * Derives a per-commitment-transaction revocation key from its constituent parts. - * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_secret always come from cheater - * and revocation_base_secret always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Derives a per-commitment-transaction revocation public key from its constituent parts. This is - * the public equivalend of derive_private_revocation_key - using only public keys to derive a - * public key instead of private keys. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_point always come from cheater - * and revocation_base_point always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKPublicKey derive_public_revocation_key(struct LDKPublicKey per_commitment_point, struct LDKPublicKey countersignatory_revocation_base_point); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Create a blank Features with no features set */ -struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Returns true if this `Features` object contains required features unknown by `other`. */ -void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKPublicKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Broadcaster's HTLC Key + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Broadcaster's HTLC Key + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Countersignatory's HTLC Key + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -struct LDKPublicKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * Countersignatory's HTLC Key + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -struct LDKPublicKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * Constructs a new TxCreationKeys given each field + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKPublicKey revocation_key_arg, struct LDKPublicKey broadcaster_htlc_key_arg, struct LDKPublicKey countersignatory_htlc_key_arg, struct LDKPublicKey broadcaster_delayed_payment_key_arg); +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * Checks if two TxCreationKeyss 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. + * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read */ -bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); +struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); /** - * Creates a copy of the TxCreationKeys + * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write */ -struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); /** - * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read */ -struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); /** - * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write */ -struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); /** - * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read */ -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); +struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write */ -struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read */ -void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); - -/** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); + +/** + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write */ -struct LDKPublicKey ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Set this feature as optional. */ -void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Set this feature as required. */ -struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * Checks if this feature is supported. */ -void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Set this feature as optional. */ -struct LDKPublicKey ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Set this feature as required. */ -void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Checks if this feature is supported. */ -struct LDKPublicKey ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Checks if this feature is required. */ -void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ChannelPublicKeys given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg); +MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelPublicKeys + * Set this feature as optional. */ -struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two ChannelPublicKeyss 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. + * Set this feature as required. */ -bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); +void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + * Set this feature as optional. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); +void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create per-state keys from channel base points and the per-commitment point. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Set this feature as required. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, struct LDKPublicKey broadcaster_delayed_payment_base, struct LDKPublicKey broadcaster_htlc_base, struct LDKPublicKey countersignatory_revocation_base, struct LDKPublicKey countersignatory_htlc_base); +void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Generate per-state keys from channel static keys. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * A script either spendable by the revocation - * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. + * Set this feature as optional. */ -struct LDKCVec_u8Z get_revokeable_redeemscript(struct LDKPublicKey revocation_key, uint16_t contest_delay, struct LDKPublicKey broadcaster_delayed_payment_key); +void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); +void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * Checks if this feature is supported. */ -bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * Checks if this feature is required. */ -void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Checks if this feature is required. */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Set this feature as optional. */ -void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); +void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The CLTV lock-time at which this HTLC expires. + * Set this feature as required. */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The CLTV lock-time at which this HTLC expires. + * Checks if this feature is supported. */ -void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The hash of the preimage which unlocks this HTLC. + * Set this feature as optional. */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; +void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The hash of the preimage which unlocks this HTLC. + * Set this feature as required. */ -void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Checks if this feature is supported. */ -struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * Checks if this feature is required. */ -void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new HTLCOutputInCommitment given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); +MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCOutputInCommitment + * Set this feature as optional. */ -struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two HTLCOutputInCommitments 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. + * Set this feature as required. */ -bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); +void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + * Set this feature as optional. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); +void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc - * does not need to have its previous_output_index filled. + * Set this feature as required. */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, const struct LDKTxCreationKeys *NONNULL_PTR keys); +void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Gets the redeemscript for a funding output from the two funding public keys. - * Note that the order of funding public keys does not matter. + * Checks if this feature is supported. */ -struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); +MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC - * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the - * transaction which needs signing, and can be used to construct an HTLC transaction which is - * broadcastable given a counterparty HTLC signature. - * - * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the - * commitment transaction). + * Set this feature as optional. */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, bool use_non_zero_fee_anchors, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); +void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns the witness required to satisfy and spend a HTLC input. - * - * Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None + * Set this feature as required. */ -struct LDKWitness build_htlc_input_witness(struct LDKSignature local_sig, struct LDKSignature remote_sig, struct LDKThirtyTwoBytes preimage, struct LDKu8slice redeem_script, bool opt_anchors); +void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Gets the witnessScript for the to_remote output when anchors are enabled. + * Checks if this feature is supported. */ -struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Gets the witnessScript for an anchor output from the funding public key. - * The witness in the spending input must be: - * - * After 16 blocks of confirmation, an alternative satisfying witness could be: - * <> - * (empty vector required to satisfy compliance with MINIMALIF-standard rule) + * Checks if this feature is required. */ -struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); +MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Returns the witness required to satisfy and spend an anchor input. + * Checks if this feature is required. */ -struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKSignature funding_sig); +MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Holder public keys + * Set this feature as optional. */ -struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Holder public keys + * Set this feature as required. */ -void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Checks if this feature is supported. */ -uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Set this feature as optional. */ -void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Set this feature as required. */ -bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Checks if this feature is supported. */ -void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Set this feature as optional. */ -struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Set this feature as required. */ -void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); +void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if this feature is supported. */ -struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if this feature is required. */ -void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is - * serialization backwards-compatible. + * Checks if this feature is required. */ -enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is - * serialization backwards-compatible. + * Checks if this feature is required. */ -void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) - * It is intended merely for backwards compatibility with signers that need it. - * There is no support for this feature in LDK channel negotiation. + * Set this feature as optional. */ -enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_non_zero_fee_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) - * It is intended merely for backwards compatibility with signers that need it. - * There is no support for this feature in LDK channel negotiation. + * Set this feature as required. */ -void ChannelTransactionParameters_set_opt_non_zero_fee_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ChannelTransactionParameters given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, enum LDKCOption_NoneZ opt_anchors_arg, enum LDKCOption_NoneZ opt_non_zero_fee_anchors_arg); +MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTransactionParameters + * Set this feature as optional. */ -struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ChannelTransactionParameterss 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. + * Set this feature as required. */ -bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); +void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); +MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Counter-party public keys + * Set this feature as optional. */ -struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Counter-party public keys + * Set this feature as required. */ -void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Checks if this feature is supported. */ -uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Checks if this feature is required. */ -void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new CounterpartyChannelTransactionParameters given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CounterpartyChannelTransactionParameters + * Checks if this feature is required. */ -struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two CounterpartyChannelTransactionParameterss 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. + * Set this feature as optional. */ -bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); +void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Whether the late bound parameters are populated. + * Set this feature as required. */ -MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the holder is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the counterparty is the broadcaster. - * - * self.is_populated() must be true before calling this function. + * Set this feature as optional. */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + * Set this feature as required. */ -struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + * Checks if this feature is supported. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + * Set this feature as optional. */ -struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + * Set this feature as required. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); +void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the broadcaster + * Set this feature as optional. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Get the channel pubkeys for the countersignatory + * Set this feature as required. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Get the contest delay applicable to the transactions. - * Note that the contest delay was selected by the countersignatory. + * Checks if this feature is supported. */ -MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Whether the channel is outbound from the broadcaster. - * - * The boolean representing the side that initiated the channel is - * an input to the commitment number obscure factor computation. + * Checks if this feature is required. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The funding outpoint + * Checks if this feature is required. */ -MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Whether to use anchors for this channel + * Checks if this feature is required. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_opt_anchors(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * Set this feature as optional. */ -struct LDKSignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Our counterparty's signature for the transaction + * Set this feature as required. */ -void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKSignature val); +void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction - * - * Returns a copy of the field. + * Checks if this feature is supported. */ -struct LDKCVec_SignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * Set this feature as optional. */ -void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_SignatureZ val); +void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HolderCommitmentTransaction + * Set this feature as required. */ -struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + * Checks if this feature is required. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create a new holder transaction with the given counterparty signatures. - * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKSignature counterparty_sig, struct LDKCVec_SignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); +MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The commitment transaction + * Set this feature as required. */ -struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The commitment transaction + * Checks if this feature is supported. */ -void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); +MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Set this feature as optional. */ -const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Set this feature as required. */ -void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new BuiltCommitmentTransaction given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BuiltCommitmentTransaction + * Set this feature as optional. */ -struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + * Set this feature as required. */ -struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + * Checks if this feature is supported. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Signs the counterparty's commitment transaction. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Signs the holder commitment transaction because we are about to broadcast it. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ClosingTransaction_free(struct LDKClosingTransaction this_obj); +void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosingTransaction + * Set this feature as required. */ -struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); +void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. + * Checks if this feature is supported. */ -uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); +MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClosingTransactions 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. + * Set this feature as optional. */ -bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Construct an object of the class + * Set this feature as required. */ -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); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Verify our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Set this feature as optional. */ -MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the holder, or zero if the output will be omitted + * Set this feature as required. */ -MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty, or zero if the output will be omitted + * Checks if this feature is supported. */ -MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The destination of the holder's output + * Checks if this feature is required. */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The destination of the counterparty's output + * Checks if this feature is required. */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The pre-built Bitcoin commitment transaction + * Set this feature as optional. */ -MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Set this feature as required. */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the CommitmentTransaction + * Set this feature as required. */ -struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + * Checks if this feature is required. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The backwards-counting commitment number + * Checks if this feature is required. */ -MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the broadcaster + * Set this feature as optional. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The value to be sent to the counterparty + * Set this feature as required. */ -MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. + * Checks if this feature is supported. */ -MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Trust our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Verify our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Set this feature as required. */ -MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The transaction ID of the built Bitcoin transaction + * Checks if this feature is required. */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The pre-built Bitcoin commitment transaction + * Checks if this feature is required. */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The pre-calculated transaction creation public keys. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Should anchors be used. + * Set this feature as required. */ -MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Get a signature for each HTLC which was included in the commitment transaction (ie for - * which HTLCOutputInCommitment::transaction_output_index.is_some()). - * - * The returned Vec has one entry for each HTLC, and in the same order. - * - * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); +MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a - * shared secret first. This prevents on-chain observers from discovering how many commitment - * transactions occurred in a channel before it was closed. - * - * This function gets the shared secret from relevant channel public keys and can be used to - * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. + * Set this feature as optional. */ -uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two InitFeaturess 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. + * Set this feature as required. */ -bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); +void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two NodeFeaturess 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. + * Checks if this feature is supported. */ -bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ChannelFeaturess 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. + * Checks if this feature is required. */ -bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two InvoiceFeaturess 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. + * Checks if this feature is required. */ -bool InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two OfferFeaturess 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. + * Set this feature as optional. */ -bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); +void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two InvoiceRequestFeaturess 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. + * Set this feature as required. */ -bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); +void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two Bolt12InvoiceFeaturess 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. + * Checks if this feature is supported. */ -bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two BlindedHopFeaturess 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. + * Set this feature as optional. */ -bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); +void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ChannelTypeFeaturess 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. + * Set this feature as required. */ -bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); +void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InitFeatures + * Checks if this feature is supported. */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the NodeFeatures + * Set this feature as optional. */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelFeatures + * Set this feature as required. */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InvoiceFeatures + * Checks if this feature is supported. */ -struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); +MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the OfferFeatures + * Checks if this feature is required. */ -struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the InvoiceRequestFeatures + * Checks if this feature is required. */ -struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Bolt12InvoiceFeatures + * Checks if this feature is required. */ -struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); +MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BlindedHopFeatures + * Set this feature as optional. */ -struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); +void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTypeFeatures + * Set this feature as required. */ -struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); +void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); +void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void OfferFeatures_free(struct LDKOfferFeatures this_obj); +MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); +void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); +void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); +MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); +void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as required. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Checks if this feature is required. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is required. */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Checks if this feature is required. */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); +MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Set this feature as optional. */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Set this feature as required. */ -MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); +void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if this feature is supported. */ -MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Checks if this feature is required. */ -MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); +MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +void ShutdownScript_free(struct LDKShutdownScript this_obj); /** - * Create a blank Features with no features set + * Creates a copy of the ShutdownScript */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); +struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if two ShutdownScripts 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. */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); /** - * Create a blank Features with no features set + * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); +void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKu8slice InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); /** - * Create a blank Features with no features set + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); +void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Constructs a new InvalidShutdownScript given each field */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); /** - * Create a blank Features with no features set + * Creates a copy of the InvalidShutdownScript */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); +struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Read a ShutdownScript from a byte array, created by ShutdownScript_write */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Generates a P2WSH script pubkey from the given [`WScriptHash`]. */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Generates a witness script pubkey from the given segwit version and program. + * + * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or + * [`ShutdownScript::new_p2wsh`] instead. + * + * # Errors + * + * This function may return an error if `program` is invalid for the segwit `version`. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessVersion version, struct LDKu8slice program); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Converts the shutdown script into the underlying [`Script`]. */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); /** - * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read + * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. + * + * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. */ -struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); +MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); /** - * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write + * Frees any resources used by the Retry */ -struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); +void Retry_free(struct LDKRetry this_ptr); /** - * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read + * Creates a copy of the Retry */ -struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); +struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); /** - * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write + * Utility method to constructs a new Attempts-variant Retry */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); +struct LDKRetry Retry_attempts(uintptr_t a); /** - * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read + * Utility method to constructs a new Timeout-variant Retry */ -struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); +struct LDKRetry Retry_timeout(uint64_t a); /** - * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + * Checks if two Retrys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); +bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Set this feature as optional. + * Generates a non-cryptographic 64-bit hash of the Retry. */ -void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); /** - * Set this feature as required. + * Creates a copy of the RetryableSendFailure */ -void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure */ -MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); /** - * Set this feature as optional. + * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure */ -void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); /** - * Set this feature as required. + * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure */ -void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); /** - * Checks if this feature is supported. + * Checks if two RetryableSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); /** - * Checks if this feature is required. + * Frees any resources used by the PaymentSendFailure */ -MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** - * Checks if this feature is required. + * Creates a copy of the PaymentSendFailure */ -MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new ParameterError-variant PaymentSendFailure */ -void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); /** - * Set this feature as required. + * Utility method to constructs a new PathParameterError-variant PaymentSendFailure */ -void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); /** - * Checks if this feature is supported. + * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure */ -MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); /** - * Set this feature as optional. + * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure */ -void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); /** - * Set this feature as required. + * Utility method to constructs a new PartialFailure-variant PaymentSendFailure */ -void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); /** - * Checks if this feature is supported. + * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); /** - * Set this feature as optional. + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_PaymentSecretZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_PaymentSecretZ val); /** - * Checks if this feature is supported. + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. + * + * Returns a copy of the field. */ -MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. */ -MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Checks if this feature is required. + * Constructs a new RecipientOnionFields given each field */ -MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_new(struct LDKCOption_PaymentSecretZ payment_secret_arg, struct LDKCOption_CVec_u8ZZ payment_metadata_arg); /** - * Set this feature as optional. + * Creates a copy of the RecipientOnionFields */ -void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); /** - * Set this feature as required. + * Checks if two RecipientOnionFieldss 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. */ -void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read */ -MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); /** - * Set this feature as optional. + * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write */ -void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); /** - * Set this feature as required. + * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common + * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] + * but do not require or provide any further data. */ -void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); /** - * Checks if this feature is supported. + * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create + * payable HTLCs except for single-path spontaneous payments, i.e. this should generally + * only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending + * a spontaneous MPP this will not work as all MPP require payment secrets; you may + * instead want to use [`RecipientOnionFields::secret_only`]. + * + * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment + * [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only */ -MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); /** - * Checks if this feature is required. + * Calls the free function if one is set */ -MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); /** - * Checks if this feature is required. + * Calls the free function if one is set */ -MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Type_free(struct LDKType this_ptr); /** - * Set this feature as optional. + * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); /** - * Set this feature as required. + * The public key corresponding to the key needed to sign the invoice. */ -void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); /** - * Set this feature as optional. + * Creates a copy of the Bolt12Invoice */ -void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); /** - * Set this feature as required. + * A complete description of the purpose of the originating offer or refund. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. */ -void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Duration since the Unix epoch when the invoice was created. */ -MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore + * should no longer be paid. */ -void InvoiceFeatures_set_variable_length_onion_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Whether the invoice has expired. */ -void InvoiceFeatures_set_variable_length_onion_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -MUST_USE_RES bool InvoiceFeatures_supports_variable_length_onion(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The minimum amount required for a successful payment of the invoice. */ -MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to paying an invoice. */ -MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The public key corresponding to the key used to sign the invoice. */ -MUST_USE_RES bool InvoiceFeatures_requires_variable_length_onion(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Hash that was used for signing the invoice. */ -void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Verifies that the invoice was for a request or refund created using the given key. */ -void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt12Invoice_verify(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Checks if this feature is supported. + * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read */ -MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); /** - * Set this feature as optional. + * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); /** - * Set this feature as required. + * Base fee charged (in millisatoshi) for the entire blinded path. */ -void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * Base fee charged (in millisatoshi) for the entire blinded path. */ -MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Set this feature as optional. + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if this feature is supported. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Checks if this feature is required. + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as optional. + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is supported. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * Set this feature as required. + * Constructs a new BlindedPayInfo given each field */ -void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); /** - * Checks if this feature is supported. + * Creates a copy of the BlindedPayInfo */ -MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); /** - * Set this feature as optional. + * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. */ -void InvoiceFeatures_set_payment_secret_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); /** - * Set this feature as required. + * Checks if two BlindedPayInfos 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. */ -void InvoiceFeatures_set_payment_secret_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read */ -MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); /** - * Checks if this feature is required. + * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write */ -MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); /** - * Checks if this feature is required. + * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void InvoiceError_free(struct LDKInvoiceError this_obj); /** - * Checks if this feature is required. + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InvoiceFeatures_requires_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); /** - * Set this feature as required. + * An explanation of the error. */ -void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * An explanation of the error. */ -MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Set this feature as optional. + * Constructs a new InvoiceError given each field */ -void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); /** - * Set this feature as required. + * Creates a copy of the InvoiceError */ -void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void ErroneousField_free(struct LDKErroneousField this_obj); /** - * Set this feature as optional. + * The type number of the TLV field containing the error. */ -void InvoiceFeatures_set_basic_mpp_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The type number of the TLV field containing the error. */ -void InvoiceFeatures_set_basic_mpp_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is supported. + * A value to use for the TLV field to avoid the error. + * + * Returns a copy of the field. */ -MUST_USE_RES bool InvoiceFeatures_supports_basic_mpp(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * A value to use for the TLV field to avoid the error. */ -void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Set this feature as required. + * Constructs a new ErroneousField given each field */ -void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); /** - * Checks if this feature is supported. + * Creates a copy of the ErroneousField */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read */ -MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); /** - * Checks if this feature is required. + * Read a InvoiceError from a byte array, created by InvoiceError_write */ -MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); /** - * Checks if this feature is required. + * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InvoiceFeatures_requires_basic_mpp(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); /** - * Checks if this feature is required. + * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); /** - * Set this feature as optional. + * Creates a copy of the InvoiceRequest */ -void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); /** - * Set this feature as required. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * A chain from [`Offer::chains`] that the offer is valid for. */ -MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Features pertaining to requesting an invoice. */ -void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Verifies that the request was for an offer created using the given key. Returns the derived + * keys need to sign an [`Bolt12Invoice`] for the request if they could be extracted from the + * metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_COption_KeyPairZNoneZ InvoiceRequest_verify(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Set this feature as required. + * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); /** - * Checks if this feature is supported. + * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void Offer_free(struct LDKOffer this_obj); /** - * Set this feature as optional. + * Creates a copy of the Offer */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); /** - * Set this feature as required. + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_ChainHashZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns whether the given chain is supported by the offer. */ -MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); /** - * Set this feature as optional. + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The minimum amount required for a successful payment of a single item. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKAmount Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to the offer. */ -MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures Offer_features(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_DurationZ Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Whether the offer has expired. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedPathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The quantity of items supported. */ -MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns whether the given quantity is valid for the offer. */ -void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); /** - * Set this feature as required. + * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The public key used by the recipient to sign invoices. */ -MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Serialize the Offer object into a byte array which can be read by Offer_read */ -MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); /** - * Checks if this feature is required. + * Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Amount_free(struct LDKAmount this_obj); /** - * Set this feature as optional. + * Creates a copy of the Amount */ -void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); /** - * Set this feature as required. + * Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Quantity_free(struct LDKQuantity this_obj); /** - * Checks if this feature is supported. + * Creates a copy of the Quantity */ -MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); /** - * Set this feature as optional. + * Read a Offer object from a string */ -void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); /** - * Set this feature as required. + * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); /** - * Checks if this feature is supported. + * Creates a copy of the Bolt12ParseError */ -MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Creates a copy of the Bolt12SemanticError */ -MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError */ -MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); /** - * Set this feature as optional. + * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError */ -void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); /** - * Set this feature as required. + * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError */ -void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError */ -MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); /** - * Set this feature as optional. + * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError */ -void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); /** - * Set this feature as required. + * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError */ -void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError */ -MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); /** - * Checks if this feature is required. + * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError */ -MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); /** - * Checks if this feature is required. + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError */ -MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); /** - * Set this feature as optional. + * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError */ -void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); /** - * Set this feature as required. + * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError */ -void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError */ -MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); /** - * Set this feature as optional. + * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError */ -void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); /** - * Set this feature as required. + * Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError */ -void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_signing_pubkey(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError */ -MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); /** - * Set this feature as optional. + * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError */ -void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); /** - * Set this feature as required. + * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError */ -void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError */ -MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); /** - * Checks if this feature is required. + * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError */ -MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); /** - * Checks if this feature is required. + * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError */ -MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); /** - * Checks if this feature is required. + * Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError */ -MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_id(void); /** - * Set this feature as optional. + * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError */ -void InvoiceFeatures_set_payment_metadata_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); /** - * Set this feature as required. + * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError */ -void InvoiceFeatures_set_payment_metadata_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError */ -MUST_USE_RES bool InvoiceFeatures_supports_payment_metadata(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); /** - * Checks if this feature is required. + * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError */ -MUST_USE_RES bool InvoiceFeatures_requires_payment_metadata(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); /** - * Set this feature as optional. + * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError */ -void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); /** - * Set this feature as required. + * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Refund_free(struct LDKRefund this_obj); /** - * Checks if this feature is supported. + * Creates a copy of the Refund */ -MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); /** - * Set this feature as optional. + * A complete description of the purpose of the refund. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. */ -void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Duration since the Unix epoch when an invoice should no longer be sent. + * + * If `None`, the refund does not expire. */ -void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_DurationZ Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Whether the refund has expired. */ -MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender + * privacy by obfuscating its node id. */ -void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedPathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice Refund_metadata(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * A chain that the refund is valid for. */ -MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). + * + * [`chain`]: Self::chain */ -MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to requesting an invoice. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The quantity of an item that refund is for. */ -void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Set this feature as required. + * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly + * transient pubkey. + * + * [`paths`]: Self::paths */ -void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Payer provided note to include in the invoice. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Serialize the Refund object into a byte array which can be read by Refund_read */ -MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); /** - * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. + * Read a Refund object from a string */ -void ShutdownScript_free(struct LDKShutdownScript this_obj); +struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); /** - * Creates a copy of the ShutdownScript + * Creates a copy of the UtxoLookupError */ -struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); +enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); /** - * Checks if two ShutdownScripts 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. + * Utility method to constructs a new UnknownChain-variant UtxoLookupError */ -bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); +enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); /** - * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnknownTx-variant UtxoLookupError */ -void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); +enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * Frees any resources used by the UtxoResult */ -struct LDKu8slice InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); +void UtxoResult_free(struct LDKUtxoResult this_ptr); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * Creates a copy of the UtxoResult */ -void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); /** - * Constructs a new InvalidShutdownScript given each field + * Utility method to constructs a new Sync-variant UtxoResult */ -MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); +struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); /** - * Creates a copy of the InvalidShutdownScript + * Utility method to constructs a new Async-variant UtxoResult */ -struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); +struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); /** - * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); +void UtxoLookup_free(struct LDKUtxoLookup this_ptr); /** - * Read a ShutdownScript from a byte array, created by ShutdownScript_write + * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); +void UtxoFuture_free(struct LDKUtxoFuture this_obj); /** - * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. + * Creates a copy of the UtxoFuture */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); +struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); /** - * Generates a P2WSH script pubkey from the given [`WScriptHash`]. + * Builds a new future for later resolution. */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); +MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); /** - * Generates a witness script pubkey from the given segwit version and program. + * Resolves this future against the given `graph` and with the given `result`. * - * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or - * [`ShutdownScript::new_p2wsh`] instead. + * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling + * forwarding the validated gossip message onwards to peers. * - * # Errors + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. * - * This function may return an error if `program` is invalid for the segwit `version`. - */ -MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessVersion version, struct LDKu8slice program); - -/** - * Converts the shutdown script into the underlying [`Script`]. + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); +void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. + * Resolves this future against the given `graph` and with the given `result`. + * + * The given `gossip` is used to broadcast any validated messages onwards to all peers which + * have available buffer space. + * + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); +void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. - * - * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. + * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); +void NodeId_free(struct LDKNodeId this_obj); /** - * Frees any resources used by the Retry + * Creates a copy of the NodeId */ -void Retry_free(struct LDKRetry this_ptr); +struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); /** - * Creates a copy of the Retry + * Create a new NodeId from a public key */ -struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); +MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); /** - * Utility method to constructs a new Attempts-variant Retry + * Get the public key slice from this NodeId */ -struct LDKRetry Retry_attempts(uintptr_t a); +MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Timeout-variant Retry + * Get the public key from this NodeId */ -struct LDKRetry Retry_timeout(uint64_t a); +MUST_USE_RES struct LDKCResult_PublicKeyErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Checks if two Retrys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Generates a non-cryptographic 64-bit hash of the NodeId. */ -bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); +uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the Retry. + * Serialize the NodeId object into a byte array which can be read by NodeId_read */ -uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); +struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); /** - * Creates a copy of the RetryableSendFailure + * Read a NodeId from a byte array, created by NodeId_write */ -enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); +struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); /** - * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. */ -enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); +void NetworkGraph_free(struct LDKNetworkGraph this_obj); /** - * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure + * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ -enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); +void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); /** - * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure + * Frees any resources used by the NetworkUpdate */ -enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); +void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); /** - * Frees any resources used by the PaymentSendFailure + * Creates a copy of the NetworkUpdate */ -void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); /** - * Creates a copy of the PaymentSendFailure + * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate */ -struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); +struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); /** - * Utility method to constructs a new ParameterError-variant PaymentSendFailure + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ -struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); +struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); /** - * Utility method to constructs a new PathParameterError-variant PaymentSendFailure + * Utility method to constructs a new NodeFailure-variant NetworkUpdate */ -struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); +struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); /** - * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); +bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); /** - * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure + * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */ -struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); +struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); /** - * Utility method to constructs a new PartialFailure-variant PaymentSendFailure + * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write */ -struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); /** - * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. + * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. */ -void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); +void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. - * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. - * - * Note that for spontaneous payments most lightning nodes do not currently support MPP - * receives, thus you should generally never be providing a secret here for spontaneous - * payments. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming an existing [`NetworkGraph`]. + * UTXO lookup is used to make sure announced channels exist on-chain, channel data is + * correct, and the announcement is signed with channel owners' keys. */ -struct LDKThirtyTwoBytes RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. - * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. - * - * Note that for spontaneous payments most lightning nodes do not currently support MPP - * receives, thus you should generally never be providing a secret here for spontaneous - * payments. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Adds a provider used to check new announcements. Does not affect + * existing announcements unless they are updated. + * Add, update or remove the provider would replace the current one. */ -void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void P2PGossipSync_add_utxo_lookup(struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. - * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. - * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. + * Handles any network updates originating from [`Event`]s. * - * Returns a copy of the field. + * [`Event`]: crate::events::Event */ -struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); /** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. - * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. - * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. + * Gets the genesis hash for this network graph. */ -void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_genesis_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Constructs a new RecipientOnionFields given each field + * Verifies the signature of a [`NodeAnnouncement`]. + * + * Returns an error if it is invalid. */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKCOption_CVec_u8ZZ payment_metadata_arg); +struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Creates a copy of the RecipientOnionFields + * Verifies all signatures included in a [`ChannelAnnouncement`]. + * + * Returns an error if one of the signatures is invalid. */ -struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); +struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Checks if two RecipientOnionFieldss 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. + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); +struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); +struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write + * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); +void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); /** - * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common - * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] - * but do not require or provide any further data. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); +uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create - * payable HTLCs except for spontaneous payments, i.e. this should generally only be used for - * calls to [`ChannelManager::send_spontaneous_payment`]. - * - * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); +void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Calls the free function if one is set + * Whether the channel can be currently used for payments (in this one direction). */ -void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); +bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * Whether the channel can be currently used for payments (in this one direction). */ -void Type_free(struct LDKType this_ptr); +void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the UnsignedInvoice, if is_owned is set and inner is non-NULL. + * The difference in CLTV values that you must have when routing through this channel. */ -void UnsignedInvoice_free(struct LDKUnsignedInvoice this_obj); +uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The public key corresponding to the key needed to sign the invoice. + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoice_signing_pubkey(const struct LDKUnsignedInvoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. + * The minimum value, which must be relayed to the next hop via the channel */ -void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); +uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * The minimum value, which must be relayed to the next hop via the channel */ -uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * The maximum value which may be relayed to the next hop via the channel. */ -void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * The maximum value which may be relayed to the next hop via the channel. */ -uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Fees charged when the channel is used for routing */ -void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Fees charged when the channel is used for routing */ -uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); +struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Constructs a new ChannelUpdateInfo given each field */ -void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Creates a copy of the ChannelUpdateInfo */ -uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Checks if two ChannelUpdateInfos 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. */ -void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ -struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write */ -void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); /** - * Constructs a new BlindedPayInfo given each field + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** - * Creates a copy of the BlindedPayInfo + * Protocol features of a channel communicated during its announcement */ -struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + * Protocol features of a channel communicated during its announcement */ -uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); +void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Checks if two BlindedPayInfos 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. + * Source node of the first direction of a channel */ -bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); +struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read + * Source node of the first direction of a channel */ -struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); +void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write + * Details about the first direction of a channel + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); +struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. + * Details about the first direction of a channel + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. + * Source node of the second direction of a channel */ -void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); +struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Creates a copy of the InvoiceRequest + * Source node of the second direction of a channel */ -struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); +void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. + * Details about the second direction of a channel * - * [`payer_id`]: Self::payer_id - */ -MUST_USE_RES struct LDKu8slice InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); - -/** - * A chain from [`Offer::chains`] that the offer is valid for. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. + * Details about the second direction of a channel * - * [`chain`]: Self::chain + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Features pertaining to requesting an invoice. + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * A possibly transient pubkey used to sign the invoice request. + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); /** - * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read + * Creates a copy of the ChannelInfo */ -struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); /** - * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. + * Checks if two ChannelInfos 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. */ -void Offer_free(struct LDKOffer this_obj); +bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); /** - * Creates a copy of the Offer + * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ -MUST_USE_RES struct LDKCVec_ChainHashZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); /** - * Returns whether the given chain is supported by the offer. + * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ -MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); +struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); +void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); /** - * The minimum amount required for a successful payment of a single item. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the DirectedChannelInfo */ -MUST_USE_RES struct LDKAmount Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Returns information for the channel. */ -MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Features pertaining to the offer. + * Returns the maximum HTLC amount allowed over the channel in the direction. */ -MUST_USE_RES struct LDKOfferFeatures Offer_features(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t DirectedChannelInfo_htlc_maximum_msat(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * Returns the [`EffectiveCapacity`] of the channel in the direction. * - * If `None`, the offer does not expire. + * This is either the total capacity from the funding transaction, if known, or the + * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, + * otherwise. */ -MUST_USE_RES struct LDKCOption_DurationZ Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Whether the offer has expired. + * Frees any resources used by the EffectiveCapacity */ -MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the EffectiveCapacity */ -MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); /** - * The quantity of items supported. + * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity */ -MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); /** - * Returns whether the given quantity is valid for the offer. + * Utility method to constructs a new Total-variant EffectiveCapacity */ -MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); /** - * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * Utility method to constructs a new Infinite-variant EffectiveCapacity */ -MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); /** - * The public key used by the recipient to sign invoices. + * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity */ -MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); /** - * Serialize the Offer object into a byte array which can be read by Offer_read + * Utility method to constructs a new Unknown-variant EffectiveCapacity */ -struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); /** - * Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. + * Returns the effective capacity denominated in millisatoshi. */ -void Amount_free(struct LDKAmount this_obj); +MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); /** - * Creates a copy of the Amount + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ -struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); +void RoutingFees_free(struct LDKRoutingFees this_obj); /** - * Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. + * Flat routing fee in millisatoshis. */ -void Quantity_free(struct LDKQuantity this_obj); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Creates a copy of the Quantity + * Flat routing fee in millisatoshis. */ -struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); +void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -void Refund_free(struct LDKRefund this_obj); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Creates a copy of the Refund + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * A complete description of the purpose of the refund. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Constructs a new RoutingFees given each field */ -MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); /** - * Duration since the Unix epoch when an invoice should no longer be sent. - * - * If `None`, the refund does not expire. + * Checks if two RoutingFeess 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. */ -MUST_USE_RES struct LDKCOption_DurationZ Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); +bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); /** - * Whether the refund has expired. + * Creates a copy of the RoutingFees */ -MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the RoutingFees. */ -MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); +uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); /** - * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender - * privacy by obfuscating its node id. + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * Read a RoutingFees from a byte array, created by RoutingFees_write */ -MUST_USE_RES struct LDKu8slice Refund_metadata(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); /** - * A chain that the refund is valid for. + * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); /** - * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). - * - * [`chain`]: Self::chain + * Protocol features the node announced support for */ -MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); +void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * The quantity of an item that refund is for. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); +uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly - * transient pubkey. - * - * [`paths`]: Self::paths + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); +void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Payer provided note to include in the invoice. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Color assigned to the node */ -MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); +const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; /** - * Serialize the Refund object into a byte array which can be read by Refund_read + * Color assigned to the node */ -struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); +void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * Creates a copy of the UtxoLookupError + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); +struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnknownChain-variant UtxoLookupError + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); +void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * Utility method to constructs a new UnknownTx-variant UtxoLookupError + * An initial announcement of the node + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); +struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UtxoResult + * An initial announcement of the node + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UtxoResult_free(struct LDKUtxoResult this_ptr); +void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); /** - * Creates a copy of the UtxoResult + * Constructs a new NodeAnnouncementInfo given each field */ -struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); +MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKNodeAnnouncement announcement_message_arg); /** - * Utility method to constructs a new Sync-variant UtxoResult + * Creates a copy of the NodeAnnouncementInfo */ -struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); /** - * Utility method to constructs a new Async-variant UtxoResult + * Checks if two NodeAnnouncementInfos 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. */ -struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); +bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); /** - * Calls the free function if one is set + * Internet-level addresses via which one can connect to the node */ -void UtxoLookup_free(struct LDKUtxoLookup this_ptr); +MUST_USE_RES struct LDKCVec_NetAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ -void UtxoFuture_free(struct LDKUtxoFuture this_obj); +struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); /** - * Creates a copy of the UtxoFuture + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write */ -struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); /** - * Builds a new future for later resolution. + * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); +void NodeAlias_free(struct LDKNodeAlias this_obj); + +const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; + +void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Resolves this future against the given `graph` and with the given `result`. - * - * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling - * forwarding the validated gossip message onwards to peers. - * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. - * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * Constructs a new NodeAlias given each field */ -void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); +MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); /** - * Resolves this future against the given `graph` and with the given `result`. - * - * The given `gossip` is used to broadcast any validated messages onwards to all peers which - * have available buffer space. - * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. - * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * Creates a copy of the NodeAlias */ -void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); +struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); /** - * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. + * Checks if two NodeAliass 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. */ -void NodeId_free(struct LDKNodeId this_obj); +bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); /** - * Creates a copy of the NodeId + * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read */ -struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); +struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); /** - * Create a new NodeId from a public key + * Read a NodeAlias from a byte array, created by NodeAlias_write */ -MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); +struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); /** - * Get the public key slice from this NodeId + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); +void NodeInfo_free(struct LDKNodeInfo this_obj); /** - * Get the public key from this NodeId + * All valid channels a node has announced + * + * Returns a copy of the field. */ -MUST_USE_RES struct LDKCResult_PublicKeyErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); +struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the NodeId. + * All valid channels a node has announced */ -uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); +void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Serialize the NodeId object into a byte array which can be read by NodeId_read + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); +struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Read a NodeId from a byte array, created by NodeId_write + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); /** - * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + * Constructs a new NodeInfo given each field */ -void NetworkGraph_free(struct LDKNetworkGraph this_obj); +MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); /** - * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. + * Creates a copy of the NodeInfo */ -void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); +struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); /** - * Frees any resources used by the NetworkUpdate + * Checks if two NodeInfos 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. */ -void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); +bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); /** - * Creates a copy of the NetworkUpdate + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ -struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); +struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); /** - * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate + * Read a NodeInfo from a byte array, created by NodeInfo_write */ -struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); +struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); /** - * Utility method to constructs a new ChannelFailure-variant NetworkUpdate + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ -struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); +struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); /** - * Utility method to constructs a new NodeFailure-variant NetworkUpdate + * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); /** - * Checks if two NetworkUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a new, empty, network graph. */ -bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); /** - * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read + * Returns a read-only view of the network graph. */ -struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); +MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write + * The unix timestamp provided by the most recent rapid gossip sync. + * It will be set by the rapid sync process after every sync completion. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. + * Update the unix timestamp provided by the most recent rapid gossip sync. + * This should be done automatically by the rapid sync process after every sync completion. */ -void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); +void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); /** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming an existing [`NetworkGraph`]. - * UTXO lookup is used to make sure announced channels exist on-chain, channel data is - * correct, and the announcement is signed with channel owners' keys. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement. + * + * You probably don't want to call this directly, instead relying on a P2PGossipSync's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Adds a provider used to check new announcements. Does not affect - * existing announcements unless they are updated. - * Add, update or remove the provider would replace the current one. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement without verifying the associated signatures. Because we aren't + * given the associated signatures here we cannot relay the node announcement to any of our + * peers. */ -void P2PGossipSync_add_utxo_lookup(struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); /** - * Handles any network updates originating from [`Event`]s. + * Store or update channel info from a channel announcement. * - * [`Event`]: crate::events::Event + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Store or update channel info from a channel announcement. + * + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * This will skip verification of if the channel is actually on-chain. */ -struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement_no_lookup(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Store or update channel info from a channel announcement without verifying the associated + * signatures. Because we aren't given the associated signatures here we cannot relay the + * channel announcement to any of our peers. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. + * Update channel from partial announcement data received via rapid gossip sync + * + * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the + * rapid gossip sync server) + * + * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. */ -void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * Marks a channel in the graph as failed permanently. + * + * The channel and any node for which this was their last channel are removed from the graph. */ -uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * Marks a node in the graph as permanently failed, effectively removing it and its channels + * from local storage. */ -void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); +void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * Whether the channel can be currently used for payments (in this one direction). + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * Note that for users of the `lightning-background-processor` crate this method may be + * automatically called regularly for you. + * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + * This method is only available with the `std` feature. See + * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. */ -bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Whether the channel can be currently used for payments (in this one direction). + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + * This function takes the current unix time as an argument. For users with the `std` feature + * enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. */ -void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); +void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); /** - * The difference in CLTV values that you must have when routing through this channel. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel. + * + * You probably don't want to call this directly, instead relying on a P2PGossipSync's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * The difference in CLTV values that you must have when routing through this channel. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel without verifying the associated signatures. Because we aren't given the + * associated signatures here we cannot relay the channel update to any of our peers. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); /** - * The minimum value, which must be relayed to the next hop via the channel + * Returns information on a channel with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * The minimum value, which must be relayed to the next hop via the channel + * Returns the list of channels in the graph */ -void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * The maximum value which may be relayed to the next hop via the channel. + * Returns information on a node with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The maximum value which may be relayed to the next hop via the channel. + * Returns the list of nodes in the graph */ -void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * Fees charged when the channel is used for routing + * Get network addresses by node id. + * Returns None if the requested node is completely unknown, + * or if node announcement for the node was never received. */ -struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_CVec_NetAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); /** - * Fees charged when the channel is used for routing + * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. */ -void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void DefaultRouter_free(struct LDKDefaultRouter this_obj); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a new router. */ -struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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 */ -void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); /** - * Constructs a new ChannelUpdateInfo given each field + * Calls the free function if one is set */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); +void Router_free(struct LDKRouter this_ptr); /** - * Creates a copy of the ChannelUpdateInfo + * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. */ -struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); +void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); /** - * Checks if two ChannelUpdateInfos 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. + * Initialize a new `ScorerAccountingForInFlightHtlcs`. */ -bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); +MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScore scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); /** - * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read + * Serialize the ScorerAccountingForInFlightHtlcs object into a byte array which can be read by ScorerAccountingForInFlightHtlcs_read */ -struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); +struct LDKCVec_u8Z ScorerAccountingForInFlightHtlcs_write(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR obj); /** - * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); +struct LDKScore ScorerAccountingForInFlightHtlcs_as_Score(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. */ -void ChannelInfo_free(struct LDKChannelInfo this_obj); +void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); /** - * Protocol features of a channel communicated during its announcement + * Creates a copy of the InFlightHtlcs */ -struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); /** - * Protocol features of a channel communicated during its announcement + * Constructs an empty `InFlightHtlcs`. */ -void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); /** - * Source node of the first direction of a channel + * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. */ -struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); /** - * Source node of the first direction of a channel + * Adds a known HTLC given the public key of the HTLC source, target, and short channel + * id. */ -void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +void InFlightHtlcs_add_inflight_htlc(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid, uint64_t used_msat); /** - * Details about the first direction of a channel - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns liquidity in msat given the public key of the HTLC source, target, and short channel + * id. */ -struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); /** - * Details about the first direction of a channel - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); /** - * Source node of the second direction of a channel + * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write */ -struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); /** - * Source node of the second direction of a channel + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. */ -void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +void RouteHop_free(struct LDKRouteHop this_obj); /** - * Details about the second direction of a channel - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The node_id of the node at this hop. */ -struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Details about the second direction of a channel - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The node_id of the node at this hop. */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel that should be used from the previous hop to reach this node. */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The channel that should be used from the previous hop to reach this node. */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the ChannelInfo + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Checks if two ChannelInfos 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. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); +void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path + * * otherwise, this is the CLTV delta expected at the destination + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path + * * otherwise, this is the CLTV delta expected at the destination + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the DirectedChannelInfo + * Constructs a new RouteHop given each field */ -struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); +MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); /** - * Returns information for the channel. + * Creates a copy of the RouteHop */ -MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); /** - * Returns the maximum HTLC amount allowed over the channel in the direction. + * Generates a non-cryptographic 64-bit hash of the RouteHop. */ -MUST_USE_RES uint64_t DirectedChannelInfo_htlc_maximum_msat(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); /** - * Returns the [`EffectiveCapacity`] of the channel in the direction. - * - * This is either the total capacity from the funding transaction, if known, or the - * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, - * otherwise. + * Checks if two RouteHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); /** - * Frees any resources used by the EffectiveCapacity + * Serialize the RouteHop object into a byte array which can be read by RouteHop_read */ -void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); +struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); /** - * Creates a copy of the EffectiveCapacity + * Read a RouteHop from a byte array, created by RouteHop_write */ -struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); +struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); /** - * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity + * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. */ -struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); +void BlindedTail_free(struct LDKBlindedTail this_obj); /** - * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity + * The hops of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKEffectiveCapacity EffectiveCapacity_maximum_htlc(uint64_t amount_msat); +struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Total-variant EffectiveCapacity + * The hops of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); +void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); /** - * Utility method to constructs a new Infinite-variant EffectiveCapacity + * The blinding point of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); +struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Unknown-variant EffectiveCapacity + * The blinding point of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ -struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); +void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Returns the effective capacity denominated in millisatoshi. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); +uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -void RoutingFees_free(struct LDKRoutingFees this_obj); +void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); /** - * Flat routing fee in millisatoshis. + * The total amount paid on this [`Path`], excluding the fees. */ -uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Flat routing fee in millisatoshis. + * The total amount paid on this [`Path`], excluding the fees. */ -void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Constructs a new BlindedTail given each field */ -uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Creates a copy of the BlindedTail */ -void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); /** - * Constructs a new RoutingFees given each field + * Generates a non-cryptographic 64-bit hash of the BlindedTail. */ -MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); /** - * Checks if two RoutingFeess contain equal inner contents. + * Checks if two BlindedTails 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. */ -bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); +bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); /** - * Creates a copy of the RoutingFees + * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read */ -struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the RoutingFees. + * Read a BlindedTail from a byte array, created by BlindedTail_write */ -uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); +struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); /** - * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); +void Path_free(struct LDKPath this_obj); /** - * Read a RoutingFees from a byte array, created by RoutingFees_write + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); /** - * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); +void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); /** - * Protocol features the node announced support for + * The blinded path at which this path terminates, if we're sending to one, and its metadata. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); /** - * Protocol features the node announced support for + * The blinded path at which this path terminates, if we're sending to one, and its metadata. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Constructs a new Path given each field */ -uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Creates a copy of the Path */ -void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); /** - * Color assigned to the node + * Generates a non-cryptographic 64-bit hash of the Path. */ -const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; +uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); /** - * Color assigned to the node + * Checks if two Paths 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. */ -void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Gets the fees for a given path, excluding any excess paid to the recipient. */ -struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Gets the total amount paid on this [`Path`], excluding the fees. */ -void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Gets the final hop's CLTV expiry delta. */ -struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. */ -void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); +void Route_free(struct LDKRoute this_obj); /** - * Constructs a new NodeAnnouncementInfo given each field + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. */ -MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKNodeAnnouncement announcement_message_arg); +struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Creates a copy of the NodeAnnouncementInfo + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); /** - * Checks if two NodeAnnouncementInfos 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. + * The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); +struct LDKPaymentParameters Route_get_payment_params(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Internet-level addresses via which one can connect to the node + * The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCVec_NetAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void Route_set_payment_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** - * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + * Constructs a new Route given each field */ -struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKPaymentParameters payment_params_arg); /** - * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + * Creates a copy of the Route */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); /** - * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the Route. */ -void NodeAlias_free(struct LDKNodeAlias this_obj); - -const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; - -void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); /** - * Constructs a new NodeAlias given each field + * Checks if two Routes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); +bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); /** - * Creates a copy of the NodeAlias + * 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 [`find_route`]'s `route_params.final_value_msat`. */ -struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); +MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); /** - * Checks if two NodeAliass 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. + * Returns the total amount paid on this [`Route`], excluding the fees. Might be more than + * requested if we had to reach htlc_minimum_msat. */ -bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); +MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); /** - * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + * Serialize the Route object into a byte array which can be read by Route_read */ -struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); +struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); /** - * Read a NodeAlias from a byte array, created by NodeAlias_write + * Read a Route from a byte array, created by Route_write */ -struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); +struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); /** - * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. */ -void NodeInfo_free(struct LDKNodeInfo this_obj); +void RouteParameters_free(struct LDKRouteParameters this_obj); /** - * All valid channels a node has announced - * - * Returns a copy of the field. + * The parameters of the failed payment path. */ -struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * All valid channels a node has announced + * The parameters of the failed payment path. */ -void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The amount in msats sent on the failed payment path. */ -struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The amount in msats sent on the failed payment path. */ -void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); +void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new NodeInfo given each field + * Constructs a new RouteParameters given each field */ -MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg); /** - * Creates a copy of the NodeInfo + * Creates a copy of the RouteParameters */ -struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); /** - * Checks if two NodeInfos contain equal inner contents. + * Checks if two RouteParameterss 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. */ -bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); +bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); /** - * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read */ -struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); /** - * Read a NodeInfo from a byte array, created by NodeInfo_write + * Read a RouteParameters from a byte array, created by RouteParameters_write */ -struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); /** - * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +void PaymentParameters_free(struct LDKPaymentParameters this_obj); /** - * Read a NetworkGraph from a byte array, created by NetworkGraph_write + * Information about the payee, such as their features and route hints for their channels. */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); +struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Creates a new, empty, network graph. + * Information about the payee, such as their features and route hints for their channels. */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); +void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); /** - * Returns a read-only view of the network graph. + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * The unix timestamp provided by the most recent rapid gossip sync. - * It will be set by the rapid sync process after every sync completion. + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Update the unix timestamp provided by the most recent rapid gossip sync. - * This should be done automatically by the rapid sync process after every sync completion. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); +uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement. - * - * You probably don't want to call this directly, instead relying on a P2PGossipSync's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); +void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement without verifying the associated signatures. Because we aren't - * given the associated signatures here we cannot relay the node announcement to any of our - * peers. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); +uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a P2PGossipSync's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * Store or update channel info from a channel announcement without verifying the associated - * signatures. Because we aren't given the associated signatures here we cannot relay the - * channel announcement to any of our peers. + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Update channel from partial announcement data received via rapid gossip sync + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. * - * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the - * rapid gossip sync server) + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. * - * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); +void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * Marks a channel in the graph as failed permanently. + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. * - * The channel and any node for which this was their last channel are removed from the graph. + * Returns a copy of the field. */ -void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Marks a node in the graph as permanently failed, effectively removing it and its channels - * from local storage. + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. */ -void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * Note that for users of the `lightning-background-processor` crate this method may be - * automatically called regularly for you. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This method is only available with the `std` feature. See - * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. + * Constructs a new PaymentParameters given each field */ -void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPayee payee_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg); /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This function takes the current unix time as an argument. For users with the `std` feature - * enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. + * Creates a copy of the PaymentParameters */ -void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); +struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel. - * - * You probably don't want to call this directly, instead relying on a P2PGossipSync's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If built with `no-std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Generates a non-cryptographic 64-bit hash of the PaymentParameters. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel without verifying the associated signatures. Because we aren't given the - * associated signatures here we cannot relay the channel update to any of our peers. - * - * If built with `no-std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Checks if two PaymentParameterss 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. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); +bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); /** - * Returns information on a channel with the given id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read */ -MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); /** - * Returns the list of channels in the graph + * Read a PaymentParameters from a byte array, created by PaymentParameters_write */ -MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); /** - * Returns information on a node with the given id. + * Creates a payee with the node id of the given `pubkey`. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. */ -MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); /** - * Returns the list of nodes in the graph + * Creates a payee with the node id of the given `pubkey` to use for keysend payments. + * + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. + * + * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose + * whether your router will be allowed to find a multi-part route for this payment. If you + * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via + * [`RecipientOnionFields::secret_only`]. + * + * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only */ -MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); /** - * Get network addresses by node id. - * Returns None if the requested node is completely unknown, - * or if node announcement for the node was never received. + * Creates parameters for paying to a blinded payee from the provided invoice. Sets + * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and + * [`PaymentParameters::expiry_time`]. */ -MUST_USE_RES struct LDKCOption_CVec_NetAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); /** - * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Payee */ -void DefaultRouter_free(struct LDKDefaultRouter this_obj); +void Payee_free(struct LDKPayee this_ptr); /** - * Creates a new router. + * Creates a copy of the Payee */ -MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes, struct LDKLockableScore scorer); +struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); /** - * 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 + * Utility method to constructs a new Blinded-variant Payee */ -struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +struct LDKPayee Payee_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints, struct LDKBolt12InvoiceFeatures features); /** - * Calls the free function if one is set + * Utility method to constructs a new Clear-variant Payee */ -void Router_free(struct LDKRouter this_ptr); +struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); /** - * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the Payee. */ -void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); +uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); /** - * Initialize a new `ScorerAccountingForInFlightHtlcs`. + * Checks if two Payees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScore scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); +bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); /** - * Serialize the ScorerAccountingForInFlightHtlcs object into a byte array which can be read by ScorerAccountingForInFlightHtlcs_read + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ScorerAccountingForInFlightHtlcs_write(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR obj); +void RouteHint_free(struct LDKRouteHint this_obj); + +struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); + +void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * Constructs a new RouteHint given each field */ -struct LDKScore ScorerAccountingForInFlightHtlcs_as_Score(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); /** - * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + * Creates a copy of the RouteHint */ -void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * Creates a copy of the InFlightHtlcs + * Generates a non-cryptographic 64-bit hash of the RouteHint. */ -struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); +uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); /** - * Constructs an empty `InFlightHtlcs`. + * Checks if two RouteHints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); +bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); /** - * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + * Serialize the RouteHint object into a byte array which can be read by RouteHint_read */ -void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); +struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); /** - * Returns liquidity in msat given the public key of the HTLC source, target, and short channel - * id. + * Read a RouteHint from a byte array, created by RouteHint_write */ -MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); +struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); /** - * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); +void RouteHintHop_free(struct LDKRouteHintHop this_obj); /** - * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + * The node_id of the non-target end of the route */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); +struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + * The node_id of the non-target end of the route */ -void RouteHop_free(struct LDKRouteHop this_obj); +void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The node_id of the node at this hop. + * The short_channel_id of this channel */ -struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); +uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The node_id of the node at this hop. + * The short_channel_id of this channel */ -void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * The fees which must be paid to use this channel */ -struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * The fees which must be paid to use this channel */ -void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * The channel that should be used from the previous hop to reach this node. + * The difference in CLTV values between this node and the next node. */ -uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); +uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The channel that should be used from the previous hop to reach this node. + * The difference in CLTV values between this node and the next node. */ -void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * The minimum value, in msat, which must be relayed to the next hop. */ -struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * The minimum value, in msat, which must be relayed to the next hop. */ -void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * The maximum value in msat available for routing with a single HTLC. */ -uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * The maximum value in msat available for routing with a single HTLC. */ -void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path - * * otherwise, this is the CLTV delta expected at the destination - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Constructs a new RouteHintHop given each field */ -uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path - * * otherwise, this is the CLTV delta expected at the destination - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Creates a copy of the RouteHintHop */ -void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * Constructs a new RouteHop given each field + * Generates a non-cryptographic 64-bit hash of the RouteHintHop. */ -MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg); +uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); /** - * Creates a copy of the RouteHop + * Checks if two RouteHintHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); +bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the RouteHop. + * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read */ -uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); +struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); /** - * Checks if two RouteHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a RouteHintHop from a byte array, created by RouteHintHop_write */ -bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); +struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); /** - * Serialize the RouteHop object into a byte array which can be read by RouteHop_read + * Finds a route from us (payer) to the given target node (payee). + * + * If the payee provided features in their invoice, they should be provided via the `payee` field + * in the given [`RouteParameters::payment_params`]. + * 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 the `payee` field + * of [`RouteParameters::payment_params`]. + * + * 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 these channels + * from `network_graph` 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. + * + * # Panics + * + * Panics if first_hops contains channels without `short_channel_id`s; + * [`ChannelManager::list_usable_channels`] will never include such channels. + * + * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); +struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); /** - * Read a RouteHop from a byte array, created by RouteHop_write + * Construct a route from us (payer) to the target node (payee) via the given hops (which should + * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. + * + * Re-uses logic from `find_route`, so the restrictions described there also apply here. */ -struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); +struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); /** - * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void BlindedTail_free(struct LDKBlindedTail this_obj); +void Score_free(struct LDKScore this_ptr); /** - * The hops of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Calls the free function if one is set */ -struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +void LockableScore_free(struct LDKLockableScore this_ptr); /** - * The hops of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Calls the free function if one is set */ -void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +void WriteableScore_free(struct LDKWriteableScore this_ptr); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. */ -struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Constructs a new LockableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is */ -void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read */ -uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Constructs a new WriteableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is */ -void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); +struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * The total amount paid on this [`Path`], excluding the fees. + * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. */ -uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); /** - * The total amount paid on this [`Path`], excluding the fees. + * Frees any resources used by the MultiThreadedScoreLock, if is_owned is set and inner is non-NULL. */ -void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); +void MultiThreadedScoreLock_free(struct LDKMultiThreadedScoreLock this_obj); /** - * Constructs a new BlindedTail given each field + * Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read */ -MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); +struct LDKCVec_u8Z MultiThreadedScoreLock_write(const struct LDKMultiThreadedScoreLock *NONNULL_PTR obj); /** - * Creates a copy of the BlindedTail + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); +struct LDKScore MultiThreadedScoreLock_as_Score(const struct LDKMultiThreadedScoreLock *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the BlindedTail. + * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. */ -uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); +void ChannelUsage_free(struct LDKChannelUsage this_obj); /** - * Checks if two BlindedTails 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. + * The amount to send through the channel, denominated in millisatoshis. */ -bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); +uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read + * The amount to send through the channel, denominated in millisatoshis. */ -struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); +void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a BlindedTail from a byte array, created by BlindedTail_write + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); +uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -void Path_free(struct LDKPath this_obj); +void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * The effective capacity of the channel. */ -struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); +struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * The effective capacity of the channel. */ -void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); +void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new ChannelUsage given each field */ -struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelUsage */ -void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); +struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); /** - * Constructs a new Path given each field + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); /** - * Creates a copy of the Path + * Creates a copy of the FixedPenaltyScorer */ -struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Path. + * Creates a new scorer using `penalty_msat`. */ -uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); /** - * Checks if two Paths 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. + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); +struct LDKScore FixedPenaltyScorer_as_Score(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * Gets the fees for a given path, excluding any excess paid to the recipient. + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read */ -MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); /** - * Gets the total amount paid on this [`Path`], excluding the fees. + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write */ -MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); /** - * Gets the final hop's CLTV expiry delta. + * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); /** - * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. */ -void Route_free(struct LDKRoute this_obj); +void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ -struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ -void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); +void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The `payment_params` 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`]. + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat */ -struct LDKPaymentParameters Route_get_payment_params(const struct LDKRoute *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The `payment_params` 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`]. + * A multiplier used with the payment amount to calculate a fixed penalty applied to each + * channel, in excess of the [`base_penalty_msat`]. * - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the payment amount. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat */ -void Route_set_payment_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); +void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new Route given each field + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * Default value: 30,000 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKPaymentParameters payment_params_arg); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the Route + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * Default value: 30,000 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life */ -struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Generates a non-cryptographic 64-bit hash of the Route. + * A multiplier used in conjunction with a payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined by our latest estimates of the + * channel's liquidity, to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat */ -uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Checks if two Routes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A multiplier used in conjunction with a payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined by our latest estimates of the + * channel's liquidity, to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat */ -bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the total amount of fees paid on this [`Route`]. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. * - * This doesn't include any extra payment made to the recipient, which can happen in excess of - * the amount passed to [`find_route`]'s `params.final_value_msat`. + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. + * + * Default value: 10,000 msat + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Returns the total amount paid on this [`Route`], excluding the fees. Might be more than - * requested if we had to reach htlc_minimum_msat. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. + * + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. + * + * Default value: 10,000 msat + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Serialize the Route object into a byte array which can be read by Route_read + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined based on the history of our + * estimates of the channel's available liquidity, to determine a penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Read a Route from a byte array, created by Route_write + * A multiplier used in conjunction with the payment amount and the negative `log10` of the + * channel's success probability for the payment, as determined based on the history of our + * estimates of the channel's available liquidity, to determine a penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths + * of the payment amount, weighted by the negative `log10` of the success probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat */ -void RouteParameters_free(struct LDKRouteParameters this_obj); +uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The parameters of the failed payment path. + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. + * + * Default value: 250 msat */ -struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The parameters of the failed payment path. + * This penalty is applied when the amount we're attempting to send over a channel exceeds our + * current estimate of the channel's available liquidity. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); +uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The amount in msats sent on the failed payment path. + * This penalty is applied when the amount we're attempting to send over a channel exceeds our + * current estimate of the channel's available liquidity. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The amount in msats sent on the failed payment path. + * Creates a copy of the ProbabilisticScoringFeeParameters */ -void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); /** - * Constructs a new RouteParameters given each field + * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg); +MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); /** - * Creates a copy of the RouteParameters + * Marks the node with the given `node_id` as banned, + * i.e it will be avoided during path finding. */ -struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); +void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Checks if two RouteParameterss 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. + * Marks all nodes in the given list as banned, i.e., + * they will be avoided during path finding. */ -bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); +void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); /** - * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read + * Removes the node with the given `node_id` from the list of nodes to avoid. */ -struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); +void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Read a RouteParameters from a byte array, created by RouteParameters_write + * Sets a manual penalty for the given node. */ -struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); +void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); /** - * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. + * Removes the node with the given `node_id` from the list of manual penalties. */ -void PaymentParameters_free(struct LDKPaymentParameters this_obj); +void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The node id of the payee. + * Clears the list of manual penalties that are applied during path finding. */ -struct LDKPublicKey PaymentParameters_get_payee_pubkey(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); /** - * The node id of the payee. + * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. */ -void PaymentParameters_set_payee_pubkey(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); /** - * Features supported by the payee. + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] * - * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice - * does not contain any features. + * Note that after 16 or more half lives all historical data will be completely gone. * - * [`for_keysend`]: Self::for_keysend + * Default value: 14 days * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities */ -struct LDKInvoiceFeatures PaymentParameters_get_features(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Features supported by the payee. + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] * - * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice - * does not contain any features. + * Note that after 16 or more half lives all historical data will be completely gone. * - * [`for_keysend`]: Self::for_keysend + * Default value: 14 days * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities */ -void PaymentParameters_set_features(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKInvoiceFeatures val); +void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Hints for routing to the payee, containing channels connecting the payee to public nodes. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 6 hours + * + * # Note + * + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -struct LDKHints PaymentParameters_get_route_hints(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Hints for routing to the payee, containing channels connecting the payee to public nodes. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. + * + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. + * + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. + * + * Default value: 6 hours + * + * # Note + * + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -void PaymentParameters_set_route_hints(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKHints val); +void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Constructs a new ProbabilisticScoringDecayParameters given each field */ -struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Creates a copy of the ProbabilisticScoringDecayParameters */ -void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. */ -uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Creates a new scorer using the given scoring parameters for sending payments from a node + * through a network graph. */ -void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Dump the contents of this scorer into the configured logger. + * + * Note that this writes roughly one line per channel for which we have a liquidity estimate, + * which may be a substantial amount of log output. */ -uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Query the estimated minimum and maximum liquidity available for sending a payment over the + * channel with `scid` towards the given `target` node. */ -void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. + * Query the historical estimated minimum and maximum liquidity available for sending a + * payment over the channel with `scid` towards the given `target` node. * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. + * Returns two sets of 8 buckets. The first set describes the octiles for lower-bound + * liquidity estimates, the second set describes the octiles for upper-bound liquidity + * estimates. Each bucket describes the relative frequency at which we've seen a liquidity + * bound in the octile relative to the channel's total capacity, on an arbitrary scale. + * Because the values are slowly decayed, more recent data points are weighted more heavily + * than older datapoints. * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * When scoring, the estimated probability that an upper-/lower-bound lies in a given octile + * relative to the channel's total capacity is calculated by dividing that bucket's value with + * the total of all buckets for the given bound. * - * Default value: 2 + * For example, a value of `[0, 0, 0, 0, 0, 0, 32]` indicates that we believe the probability + * of a bound being in the top octile to be 100%, and have never (recently) seen it in any + * other octiles. A value of `[31, 0, 0, 0, 0, 0, 0, 32]` indicates we've seen the bound being + * both in the top and bottom octile, and roughly with similar (recent) frequency. + * + * Because the datapoints are decayed slowly over time, values will eventually return to + * `Some(([0; 8], [0; 8]))`. */ -uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_C2Tuple_EightU16sEightU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. - * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. - * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. - * - * Default value: 2 + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. - * - * Returns a copy of the field. + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write */ -void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); /** - * The minimum CLTV delta at the end of the route. This value must not be zero. + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -uint32_t PaymentParameters_get_final_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * The minimum CLTV delta at the end of the route. This value must not be zero. + * The outpoint which is spendable. */ -void PaymentParameters_set_final_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Constructs a new PaymentParameters given each field + * The outpoint which is spendable. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKHints route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, uint32_t final_cltv_expiry_delta_arg); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Creates a copy of the PaymentParameters + * Per commitment point to derive the delayed payment key by key holder. */ -struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the PaymentParameters. + * Per commitment point to derive the delayed payment key by key holder. */ -uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if two PaymentParameterss 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. + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Read a PaymentParameters from a byte array, created by PaymentParameters_write + * The output which is referenced by the given outpoint. */ -struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates a payee with the node id of the given `pubkey`. - * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * The output which is referenced by the given outpoint. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Creates a payee with the node id of the given `pubkey` to use for keysend payments. - * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Hints + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -void Hints_free(struct LDKHints this_ptr); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the Hints + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -struct LDKHints Hints_clone(const struct LDKHints *NONNULL_PTR orig); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new Blinded-variant Hints + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -struct LDKHints Hints_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new Clear-variant Hints + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKHints Hints_clear(struct LDKCVec_RouteHintZ a); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Hints. + * The value of the channel which this output originated from, possibly indirectly. */ -uint64_t Hints_hash(const struct LDKHints *NONNULL_PTR o); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two Hintss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new DelayedPaymentOutputDescriptor given each field */ -bool Hints_eq(const struct LDKHints *NONNULL_PTR a, const struct LDKHints *NONNULL_PTR b); +MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. + * Creates a copy of the DelayedPaymentOutputDescriptor */ -void RouteHint_free(struct LDKRouteHint this_obj); - -struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); - -void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Constructs a new RouteHint given each field + * Checks if two DelayedPaymentOutputDescriptors 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. */ -MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); /** - * Creates a copy of the RouteHint + * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ -struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); +struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the RouteHint. + * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write */ -uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Checks if two RouteHints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * Serialize the RouteHint object into a byte array which can be read by RouteHint_read + * The outpoint which is spendable. */ -struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Read a RouteHint from a byte array, created by RouteHint_write + * The outpoint which is spendable. */ -struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. + * The output which is referenced by the given outpoint. */ -void RouteHintHop_free(struct LDKRouteHintHop this_obj); +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The node_id of the non-target end of the route + * The output which is referenced by the given outpoint. */ -struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * The node_id of the non-target end of the route + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * The short_channel_id of this channel + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The short_channel_id of this channel + * The value of the channel which this transactions spends. */ -void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The fees which must be paid to use this channel + * The value of the channel which this transactions spends. */ -struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * The fees which must be paid to use this channel + * Constructs a new StaticPaymentOutputDescriptor given each field */ -void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); /** - * The difference in CLTV values between this node and the next node. + * Creates a copy of the StaticPaymentOutputDescriptor */ -uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * The difference in CLTV values between this node and the next node. + * Checks if two StaticPaymentOutputDescriptors 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. */ -void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write */ -void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * The maximum value in msat available for routing with a single HTLC. + * Frees any resources used by the SpendableOutputDescriptor */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * The maximum value in msat available for routing with a single HTLC. + * Creates a copy of the SpendableOutputDescriptor */ -void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Constructs a new RouteHintHop given each field + * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ -MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output); /** - * Creates a copy of the RouteHintHop + * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor */ -struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); /** - * Generates a non-cryptographic 64-bit hash of the RouteHintHop. + * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor */ -uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); /** - * Checks if two RouteHintHops contain equal inner contents. + * Checks if two SpendableOutputDescriptors 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. */ -bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); /** - * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * Read a RouteHintHop from a byte array, created by RouteHintHop_write + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write */ -struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); /** - * Finds a route from us (payer) to the given target node (payee). - * - * 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 `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 these channels - * from `network_graph` 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. + * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to + * the given outputs, plus an output to the given change destination (if sufficient + * change value remains). The PSBT will have a feerate, at least, of the given value. * - * # Panics + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. * - * Panics if first_hops contains channels without short_channel_ids; - * [`ChannelManager::list_usable_channels`] will never include such channels. + * Returns the PSBT and expected max transaction weight. * - * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. */ -struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer, const uint8_t (*random_seed_bytes)[32]); +MUST_USE_RES struct LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_PackedLockTimeZ locktime); /** - * Construct a route from us (payer) to the target node (payee) via the given hops (which should - * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. - * - * Re-uses logic from `find_route`, so the restrictions described there also apply here. + * Calls the free function if one is set */ -struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); +void ChannelSigner_free(struct LDKChannelSigner this_ptr); /** * Calls the free function if one is set */ -void Score_free(struct LDKScore this_ptr); +void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); /** * Calls the free function if one is set */ -void LockableScore_free(struct LDKLockableScore this_ptr); +void WriteableEcdsaChannelSigner_free(struct LDKWriteableEcdsaChannelSigner this_ptr); /** - * Calls the free function if one is set + * Creates a copy of the Recipient */ -void WriteableScore_free(struct LDKWriteableScore this_ptr); +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); /** - * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Node-variant Recipient */ -void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); +enum LDKRecipient Recipient_node(void); /** - * Frees any resources used by the MultiThreadedScoreLock, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PhantomNode-variant Recipient */ -void MultiThreadedScoreLock_free(struct LDKMultiThreadedScoreLock this_obj); +enum LDKRecipient Recipient_phantom_node(void); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * Calls the free function if one is set */ -struct LDKScore MultiThreadedScoreLock_as_Score(const struct LDKMultiThreadedScoreLock *NONNULL_PTR this_arg); +void EntropySource_free(struct LDKEntropySource this_ptr); /** - * Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z MultiThreadedScoreLock_write(const struct LDKMultiThreadedScoreLock *NONNULL_PTR obj); +void NodeSigner_free(struct LDKNodeSigner this_ptr); /** - * Constructs a new LockableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is + * Calls the free function if one is set */ -struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +void SignerProvider_free(struct LDKSignerProvider this_ptr); /** - * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * Constructs a new WriteableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. + * Holder secret key for blinded revocation pubkey. */ -void ChannelUsage_free(struct LDKChannelUsage this_obj); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The amount to send through the channel, denominated in millisatoshis. + * Holder secret key for blinded revocation pubkey. */ -uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The amount to send through the channel, denominated in millisatoshis. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Holder secret key used in an HTLC transaction. */ -void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * The effective capacity of the channel. + * Holder secret key used in an HTLC transaction. */ -struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * The effective capacity of the channel. + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Constructs a new ChannelUsage given each field + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Creates a copy of the ChannelUsage + * Commitment seed. */ -struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + * Commitment seed. */ -void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the FixedPenaltyScorer + * Creates a copy of the InMemorySigner */ -struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * Creates a new scorer using `penalty_msat`. + * Creates a new [`InMemorySigner`]. */ -MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); +MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * Returns the counterparty's pubkeys. + * + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -struct LDKScore FixedPenaltyScorer_as_Score(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable + * transactions, i.e., the amount of time that we have to wait to recover our funds if we + * broadcast a transaction. + * + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); +MUST_USE_RES uint16_t InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + * Returns the `contest_delay` value specified by us and applied on transactions broadcastable + * by our counterparty, i.e., the amount of time that they have to wait to recover their funds + * if they broadcast a transaction. + * + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); +MUST_USE_RES uint16_t InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + * Returns whether the holder is the initiator. + * + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); +MUST_USE_RES bool InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. + * Funding outpoint + * + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters this_obj); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * A fixed penalty in msats to apply to each channel. + * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or + * building transactions. * - * Default value: 500 msat + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -uint64_t ProbabilisticScoringParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * A fixed penalty in msats to apply to each channel. + * Returns the channel type features of the channel parameters. Should be helpful for + * determining a channel's category, i. e. legacy/anchors/taproot/etc. * - * Default value: 500 msat + * Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. */ -void ProbabilisticScoringParameters_set_base_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * A multiplier used with the payment amount to calculate a fixed penalty applied to each - * channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the payment amount. - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described + * by `descriptor`, returning the witness stack for the input. * - * Default value: 8,192 msat + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], + * or if an output descriptor `script_pubkey` does not match the one we can spend. * - * [`base_penalty_msat`]: Self::base_penalty_msat + * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint */ -uint64_t ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * A multiplier used with the payment amount to calculate a fixed penalty applied to each - * channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the payment amount. - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * Sign the single input of `spend_tx` at index `input_idx` which spends the output + * described by `descriptor`, returning the witness stack for the input. * - * Default value: 8,192 msat + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], does not have a + * sequence set to [`descriptor.to_self_delay`], or if an output descriptor + * `script_pubkey` does not match the one we can spend. * - * [`base_penalty_msat`]: Self::base_penalty_msat + * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint + * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay */ -void ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * Default value: 30,000 msat - * - * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * Default value: 30,000 msat - * - * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + * Constructs a new ChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is */ -void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 6 hours - * - * # Note - * - * When built with the `no-std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is */ -uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 6 hours - * - * # Note - * - * When built with the `no-std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is */ -void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKWriteableEcdsaChannelSigner InMemorySigner_as_WriteableEcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * A multiplier used in conjunction with a payment amount and the negative `log10` of the - * channel's success probability for the payment, as determined by our latest estimates of the - * channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the - * success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * Default value: 192 msat + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * A multiplier used in conjunction with a payment amount and the negative `log10` of the - * channel's success probability for the payment, as determined by our latest estimates of the - * channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the - * success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * Default value: 192 msat + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -void ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. - * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. - * - * Default value: 10,000 msat - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -uint64_t ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. + * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., + * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). + * `starting_time` isn't strictly required to actually be a time, but it must absolutely, + * without a doubt, be unique to this instance. ie if you start multiple times with the same + * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this + * is to simply use the current time (with very high precision). * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. + * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, + * obviously, `starting_time` should be unique every time you reload the library - it is only + * used to generate new ephemeral key data (which will be stored by the individual channel if + * necessary). * - * Default value: 10,000 msat + * Note that the seed is required to recover certain on-chain funds independent of + * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required + * for any channel, and some on-chain during-closing funds. * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ -void ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the payment, as determined based on the history of our - * estimates of the channel's available liquidity, to determine a penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths - * of the payment amount, weighted by the negative `log10` of the success probability. - * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + */ +MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); + +/** + * Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. + */ +MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); + +/** + * Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s. + * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there + * are no other inputs that need signing. * - * Default value: 64 msat + * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used + * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. */ -uint64_t ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_PartiallySignedTransactionNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); /** - * A multiplier used in conjunction with the payment amount and the negative `log10` of the - * channel's success probability for the payment, as determined based on the history of our - * estimates of the channel's available liquidity, to determine a penalty. + * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an + * output to the given change destination (if sufficient change value remains). The + * transaction will have a feerate, at least, of the given value. * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and the `2^20`ths - * of the payment amount, weighted by the negative `log10` of the success probability. + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. * - * Default value: 64 msat + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used + * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. */ -void ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_PackedLockTimeZ locktime); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -uint64_t ProbabilisticScoringParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is */ -void ProbabilisticScoringParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We - * treat such nodes preferentially as this makes balance discovery attacks harder to execute, - * thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is */ -uint64_t ProbabilisticScoringParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We - * treat such nodes preferentially as this makes balance discovery attacks harder to execute, - * thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScoringParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); /** - * This penalty is applied when the amount we're attempting to send over a channel exceeds our - * current estimate of the channel's available liquidity. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. - * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. - * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -uint64_t ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); +struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * This penalty is applied when the amount we're attempting to send over a channel exceeds our - * current estimate of the channel's available liquidity. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + */ +struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); + +/** + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + */ +struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); + +/** + * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` + * that is shared across all nodes that intend to participate in [phantom node payments] + * together. * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. + * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and + * `starting_time_nanos`. * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the + * same across restarts, or else inbound payments may fail. * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * [phantom node payments]: PhantomKeysManager */ -void ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); /** - * Creates a copy of the ProbabilisticScoringParameters + * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. */ -struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_TransactionNoneZ PhantomKeysManager_spend_spendable_outputs(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_PackedLockTimeZ locktime); /** - * Creates a new scorer using the given scoring parameters for sending payments from a node - * through a network graph. + * See [`KeysManager::derive_channel_keys`] for documentation on this method. */ -MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringParameters params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Dump the contents of this scorer into the configured logger. - * - * Note that this writes roughly one line per channel for which we have a liquidity estimate, - * which may be a substantial amount of log output. + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Query the estimated minimum and maximum liquidity available for sending a payment over the - * channel with `scid` towards the given `target` node. + * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the + * last-hop onion data, etc. */ -MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Query the historical estimated minimum and maximum liquidity available for sending a - * payment over the channel with `scid` towards the given `target` node. - * - * Returns two sets of 8 buckets. The first set describes the octiles for lower-bound - * liquidity estimates, the second set describes the octiles for upper-bound liquidity - * estimates. Each bucket describes the relative frequency at which we've seen a liquidity - * bound in the octile relative to the channel's total capacity, on an arbitrary scale. - * Because the values are slowly decayed, more recent data points are weighted more heavily - * than older datapoints. - * - * When scoring, the estimated probability that an upper-/lower-bound lies in a given octile - * relative to the channel's total capacity is calculated by dividing that bucket's value with - * the total of all buckets for the given bound. - * - * For example, a value of `[0, 0, 0, 0, 0, 0, 32]` indicates that we believe the probability - * of a bound being in the top octile to be 100%, and have never (recently) seen it in any - * other octiles. A value of `[31, 0, 0, 0, 0, 0, 0, 32]` indicates we've seen the bound being - * both in the top and bottom octile, and roughly with similar (recent) frequency. - * - * Because the datapoints are decayed slowly over time, values will eventually return to - * `Some(([0; 8], [0; 8]))`. + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_C2Tuple_EightU16sEightU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +void OnionMessenger_free(struct LDKOnionMessenger this_obj); /** - * Marks the node with the given `node_id` as banned, i.e., - * it will be avoided during path finding. + * Calls the free function if one is set */ -void ProbabilisticScorer_add_banned(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void MessageRouter_free(struct LDKMessageRouter this_ptr); /** - * Removes the node with the given `node_id` from the list of nodes to avoid. + * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScorer_remove_banned(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); /** - * Sets a manual penalty for the given node. + * Constructs a new DefaultMessageRouter given each field */ -void ProbabilisticScorer_set_manual_penalty(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); +MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(void); /** - * Removes the node with the given `node_id` from the list of manual penalties. + * Constructs a new MessageRouter which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is */ -void ProbabilisticScorer_remove_manual_penalty(struct LDKProbabilisticScorer *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); /** - * Clears the list of manual penalties that are applied during path finding. + * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. */ -void ProbabilisticScorer_clear_manual_penalties(struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); /** - * Marks all nodes in the given list as banned, i.e., - * they will be avoided during path finding. + * Nodes on the path between the sender and the destination. + * + * Returns a copy of the field. */ -void ProbabilisticScoringParameters_add_banned_from_list(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); +struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. + * Nodes on the path between the sender and the destination. */ -MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_default(void); +void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * The recipient of the message. */ -struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + * The recipient of the message. */ -struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); +void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); /** - * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + * Constructs a new OnionMessagePath given each field */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg); /** - * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + * Creates a copy of the OnionMessagePath */ -void OnionMessenger_free(struct LDKOnionMessenger this_obj); +struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); /** * Frees any resources used by the Destination @@ -34158,15 +40565,16 @@ void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to * their respective handlers. */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKCustomOnionMessageHandler custom_handler); /** - * Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. + * Send an onion message with contents `message` to the destination of `path`. + * * See [`OnionMessenger`] for example usage. * * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKOnionMessageContents message, struct LDKBlindedPath reply_path); +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessagePath path, struct LDKOnionMessageContents message, struct LDKBlindedPath reply_path); /** * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. @@ -34180,11 +40588,66 @@ struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct */ struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +/** + * Calls the free function if one is set + */ +void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); + +/** + * Frees any resources used by the OffersMessage + */ +void OffersMessage_free(struct LDKOffersMessage this_ptr); + +/** + * Creates a copy of the OffersMessage + */ +struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); + +/** + * Utility method to constructs a new InvoiceRequest-variant OffersMessage + */ +struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); + +/** + * Utility method to constructs a new Invoice-variant OffersMessage + */ +struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); + +/** + * Utility method to constructs a new InvoiceError-variant OffersMessage + */ +struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); + +/** + * Returns whether `tlv_type` corresponds to a TLV record for Offers. + */ +MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); + +/** + * The TLV record type for the message as used in an `onionmsg_tlv` TLV stream. + */ +MUST_USE_RES uint64_t OffersMessage_tlv_type(const struct LDKOffersMessage *NONNULL_PTR this_arg); + +/** + * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read + */ +struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); + +/** + * Read a OffersMessage from a byte array, created by OffersMessage_write + */ +struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); + /** * Frees any resources used by the OnionMessageContents */ void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); +/** + * Utility method to constructs a new Offers-variant OnionMessageContents + */ +struct LDKOnionMessageContents OnionMessageContents_offers(struct LDKOffersMessage a); + /** * Utility method to constructs a new Custom-variant OnionMessageContents */ @@ -34280,7 +40743,7 @@ struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NO /** * Utility method to constructs a new InvoicePayment-variant PaymentPurpose */ -struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); +struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKCOption_PaymentPreimageZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose @@ -34389,6 +40852,11 @@ struct LDKClosureReason ClosureReason_disconnected_peer(void); */ struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +/** + * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); + /** * Checks if two ClosureReasons contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -34520,7 +40988,7 @@ struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporar /** * Utility method to constructs a new PaymentClaimable-variant Event */ -struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKThirtyTwoBytes via_channel_id, struct LDKCOption_u128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); +struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, uint64_t counterparty_skimmed_fee_msat, struct LDKPaymentPurpose purpose, struct LDKThirtyTwoBytes via_channel_id, struct LDKCOption_u128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); /** * Utility method to constructs a new PaymentClaimed-variant Event @@ -34530,7 +40998,7 @@ struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, stru /** * Utility method to constructs a new PaymentSent-variant Event */ -struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +struct LDKEvent Event_payment_sent(struct LDKCOption_PaymentIdZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); /** * Utility method to constructs a new PaymentFailed-variant Event @@ -34540,12 +41008,12 @@ struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct /** * Utility method to constructs a new PaymentPathSuccessful-variant Event */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_PaymentHashZ payment_hash, struct LDKPath path); /** * Utility method to constructs a new PaymentPathFailed-variant Event */ -struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +struct LDKEvent Event_payment_path_failed(struct LDKCOption_PaymentIdZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** * Utility method to constructs a new ProbeSuccessful-variant Event @@ -34607,6 +41075,11 @@ struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_ch */ struct LDKEvent Event_htlchandling_failed(struct LDKThirtyTwoBytes prev_channel_id, struct LDKHTLCDestination failed_next_destination); +/** + * Utility method to constructs a new BumpTransaction-variant Event + */ +struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); + /** * Checks if two Events contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -34638,11 +41111,21 @@ struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEve */ struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +/** + * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); + /** * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent */ struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +/** + * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); + /** * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent */ @@ -34653,6 +41136,51 @@ struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPubli */ struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +/** + * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); + +/** + * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); + +/** + * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); + +/** + * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); + +/** + * Utility method to constructs a new SendTxComplete-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); + +/** + * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); + +/** + * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); + +/** + * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); + +/** + * Utility method to constructs a new SendTxAbort-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAddInput msg); + /** * Utility method to constructs a new SendChannelReady-variant MessageSendEvent */ @@ -34758,6 +41286,503 @@ void EventsProvider_free(struct LDKEventsProvider this_ptr); */ void EventHandler_free(struct LDKEventHandler this_ptr); +/** + * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. + */ +void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); + +/** + * The value in satoshis of the channel we're attempting to spend the anchor output of. + */ +uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); + +/** + * The value in satoshis of the channel we're attempting to spend the anchor output of. + */ +void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The unique identifier to re-derive the signer for the associated channel. + */ +const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; + +/** + * The unique identifier to re-derive the signer for the associated channel. + */ +void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters + */ +struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); + +/** + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters + */ +void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); + +/** + * Constructs a new ChannelDerivationParameters given each field + */ +MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); + +/** + * Creates a copy of the ChannelDerivationParameters + */ +struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); + +/** + * Checks if two ChannelDerivationParameterss 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. + */ +bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); + +/** + * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. + */ +void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); + +/** + * The parameters required to derive the signer for the anchor input. + */ +struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); + +/** + * The parameters required to derive the signer for the anchor input. + */ +void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); + +/** + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. + */ +struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); + +/** + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. + */ +void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); + +/** + * Constructs a new AnchorDescriptor given each field + */ +MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); + +/** + * Creates a copy of the AnchorDescriptor + */ +struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); + +/** + * Checks if two AnchorDescriptors 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. + */ +bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); + +/** + * Returns the UTXO to be spent by the anchor input, which can be obtained via + * [`Self::unsigned_tx_input`]. + */ +MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the unsigned transaction input spending the anchor output in the commitment + * transaction. + */ +MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the witness script of the anchor output in the commitment transaction. + */ +MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the fully signed witness required to spend the anchor output in the commitment + * transaction. + */ +MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKSignature signature); + +/** + * Derives the channel signer required to sign the anchor input. + */ +MUST_USE_RES struct LDKWriteableEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); + +/** + * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. + */ +void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); + +/** + * The parameters required to derive the signer for the HTLC input. + */ +struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The parameters required to derive the signer for the HTLC input. + */ +void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); + +/** + * The number of the commitment transaction in which the HTLC output lives. + */ +uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The number of the commitment transaction in which the HTLC output lives. + */ +void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. + * + * See for more info. + */ +struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. + * + * See for more info. + */ +void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The details of the HTLC as it appears in the commitment transaction. + */ +struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The details of the HTLC as it appears in the commitment transaction. + */ +void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); + +/** + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. + */ +struct LDKCOption_PaymentPreimageZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. + */ +void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_PaymentPreimageZ val); + +/** + * The counterparty's signature required to spend the HTLC output. + */ +struct LDKSignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); + +/** + * The counterparty's signature required to spend the HTLC output. + */ +void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKSignature val); + +/** + * Creates a copy of the HTLCDescriptor + */ +struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); + +/** + * Checks if two HTLCDescriptors 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. + */ +bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); + +/** + * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint + * being spent by the HTLC input in the HTLC transaction. + */ +MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the UTXO to be spent by the HTLC input, which can be obtained via + * [`Self::unsigned_tx_input`]. + */ +MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the unsigned transaction input spending the HTLC output in the commitment + * transaction. + */ +MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the delayed output created as a result of spending the HTLC output in the commitment + * transaction. + */ +MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the witness script of the HTLC output in the commitment transaction. + */ +MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); + +/** + * Returns the fully signed witness required to spend the HTLC output in the commitment + * transaction. + */ +MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKSignature signature, struct LDKu8slice witness_script); + +/** + * Derives the channel signer required to sign the HTLC input. + */ +MUST_USE_RES struct LDKWriteableEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); + +/** + * Frees any resources used by the BumpTransactionEvent + */ +void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); + +/** + * Creates a copy of the BumpTransactionEvent + */ +struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); + +/** + * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent + */ +struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKThirtyTwoBytes claim_id, uint32_t package_target_feerate_sat_per_1000_weight, struct LDKTransaction commitment_tx, uint64_t commitment_tx_fee_satoshis, struct LDKAnchorDescriptor anchor_descriptor, struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs); + +/** + * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent + */ +struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); + +/** + * Checks if two BumpTransactionEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); + +/** + * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. + */ +void Input_free(struct LDKInput this_obj); + +/** + * The unique identifier of the input. + */ +struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); + +/** + * The unique identifier of the input. + */ +void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); + +/** + * The UTXO being spent by the input. + */ +struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); + +/** + * The UTXO being spent by the input. + */ +void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); + +/** + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. + */ +uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); + +/** + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. + */ +void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new Input given each field + */ +MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); + +/** + * Creates a copy of the Input + */ +struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Input. + */ +uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); + +/** + * Checks if two Inputs 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. + */ +bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); + +/** + * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. + */ +void Utxo_free(struct LDKUtxo this_obj); + +/** + * The unique identifier of the output. + */ +struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); + +/** + * The unique identifier of the output. + */ +void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); + +/** + * The output to spend. + */ +struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); + +/** + * The output to spend. + */ +void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); + +/** + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + */ +uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); + +/** + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + */ +void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new Utxo given each field + */ +MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); + +/** + * Creates a copy of the Utxo + */ +struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Utxo. + */ +uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); + +/** + * Checks if two Utxos 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. + */ +bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); + +/** + * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. + */ +MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); + +/** + * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. + */ +void CoinSelection_free(struct LDKCoinSelection this_obj); + +/** + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. + */ +struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); + +/** + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. + */ +void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); + +/** + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. + */ +struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); + +/** + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. + */ +void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); + +/** + * Constructs a new CoinSelection given each field + */ +MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); + +/** + * Creates a copy of the CoinSelection + */ +struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); + +/** + * Calls the free function if one is set + */ +void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); + +/** + * Calls the free function if one is set + */ +void WalletSource_free(struct LDKWalletSource this_ptr); + +/** + * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. + */ +void Wallet_free(struct LDKWallet this_obj); + +/** + * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation + * of [`CoinSelectionSource`]. + */ +MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); + +/** + * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is + */ +struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. + */ +void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); + +/** + * Returns a new instance capable of handling [`Event::BumpTransaction`] events. + * + * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction + */ +MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); + +/** + * Handles all variants of [`BumpTransactionEvent`]. + */ +void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); + /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. */ @@ -34879,110 +41904,110 @@ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBac MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); /** - * Frees any resources used by the ParseError + * Frees any resources used by the Bolt11ParseError */ -void ParseError_free(struct LDKParseError this_ptr); +void Bolt11ParseError_free(struct LDKBolt11ParseError this_ptr); /** - * Creates a copy of the ParseError + * Creates a copy of the Bolt11ParseError */ -struct LDKParseError ParseError_clone(const struct LDKParseError *NONNULL_PTR orig); +struct LDKBolt11ParseError Bolt11ParseError_clone(const struct LDKBolt11ParseError *NONNULL_PTR orig); /** - * Utility method to constructs a new Bech32Error-variant ParseError + * Utility method to constructs a new Bech32Error-variant Bolt11ParseError */ -struct LDKParseError ParseError_bech32_error(struct LDKBech32Error a); +struct LDKBolt11ParseError Bolt11ParseError_bech32_error(struct LDKBech32Error a); /** - * Utility method to constructs a new ParseAmountError-variant ParseError + * Utility method to constructs a new ParseAmountError-variant Bolt11ParseError */ -struct LDKParseError ParseError_parse_amount_error(struct LDKError a); +struct LDKBolt11ParseError Bolt11ParseError_parse_amount_error(struct LDKError a); /** - * Utility method to constructs a new MalformedSignature-variant ParseError + * Utility method to constructs a new MalformedSignature-variant Bolt11ParseError */ -struct LDKParseError ParseError_malformed_signature(enum LDKSecp256k1Error a); +struct LDKBolt11ParseError Bolt11ParseError_malformed_signature(enum LDKSecp256k1Error a); /** - * Utility method to constructs a new BadPrefix-variant ParseError + * Utility method to constructs a new BadPrefix-variant Bolt11ParseError */ -struct LDKParseError ParseError_bad_prefix(void); +struct LDKBolt11ParseError Bolt11ParseError_bad_prefix(void); /** - * Utility method to constructs a new UnknownCurrency-variant ParseError + * Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError */ -struct LDKParseError ParseError_unknown_currency(void); +struct LDKBolt11ParseError Bolt11ParseError_unknown_currency(void); /** - * Utility method to constructs a new UnknownSiPrefix-variant ParseError + * Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError */ -struct LDKParseError ParseError_unknown_si_prefix(void); +struct LDKBolt11ParseError Bolt11ParseError_unknown_si_prefix(void); /** - * Utility method to constructs a new MalformedHRP-variant ParseError + * Utility method to constructs a new MalformedHRP-variant Bolt11ParseError */ -struct LDKParseError ParseError_malformed_hrp(void); +struct LDKBolt11ParseError Bolt11ParseError_malformed_hrp(void); /** - * Utility method to constructs a new TooShortDataPart-variant ParseError + * Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError */ -struct LDKParseError ParseError_too_short_data_part(void); +struct LDKBolt11ParseError Bolt11ParseError_too_short_data_part(void); /** - * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant ParseError + * Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError */ -struct LDKParseError ParseError_unexpected_end_of_tagged_fields(void); +struct LDKBolt11ParseError Bolt11ParseError_unexpected_end_of_tagged_fields(void); /** - * Utility method to constructs a new DescriptionDecodeError-variant ParseError + * Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError */ -struct LDKParseError ParseError_description_decode_error(struct LDKError a); +struct LDKBolt11ParseError Bolt11ParseError_description_decode_error(struct LDKError a); /** - * Utility method to constructs a new PaddingError-variant ParseError + * Utility method to constructs a new PaddingError-variant Bolt11ParseError */ -struct LDKParseError ParseError_padding_error(void); +struct LDKBolt11ParseError Bolt11ParseError_padding_error(void); /** - * Utility method to constructs a new IntegerOverflowError-variant ParseError + * Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError */ -struct LDKParseError ParseError_integer_overflow_error(void); +struct LDKBolt11ParseError Bolt11ParseError_integer_overflow_error(void); /** - * Utility method to constructs a new InvalidSegWitProgramLength-variant ParseError + * Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError */ -struct LDKParseError ParseError_invalid_seg_wit_program_length(void); +struct LDKBolt11ParseError Bolt11ParseError_invalid_seg_wit_program_length(void); /** - * Utility method to constructs a new InvalidPubKeyHashLength-variant ParseError + * Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError */ -struct LDKParseError ParseError_invalid_pub_key_hash_length(void); +struct LDKBolt11ParseError Bolt11ParseError_invalid_pub_key_hash_length(void); /** - * Utility method to constructs a new InvalidScriptHashLength-variant ParseError + * Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError */ -struct LDKParseError ParseError_invalid_script_hash_length(void); +struct LDKBolt11ParseError Bolt11ParseError_invalid_script_hash_length(void); /** - * Utility method to constructs a new InvalidRecoveryId-variant ParseError + * Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError */ -struct LDKParseError ParseError_invalid_recovery_id(void); +struct LDKBolt11ParseError Bolt11ParseError_invalid_recovery_id(void); /** - * Utility method to constructs a new InvalidSliceLength-variant ParseError + * Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError */ -struct LDKParseError ParseError_invalid_slice_length(struct LDKStr a); +struct LDKBolt11ParseError Bolt11ParseError_invalid_slice_length(struct LDKStr a); /** - * Utility method to constructs a new Skip-variant ParseError + * Utility method to constructs a new Skip-variant Bolt11ParseError */ -struct LDKParseError ParseError_skip(void); +struct LDKBolt11ParseError Bolt11ParseError_skip(void); /** - * Checks if two ParseErrors contain equal inner contents. + * Checks if two Bolt11ParseErrors contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool ParseError_eq(const struct LDKParseError *NONNULL_PTR a, const struct LDKParseError *NONNULL_PTR b); +bool Bolt11ParseError_eq(const struct LDKBolt11ParseError *NONNULL_PTR a, const struct LDKBolt11ParseError *NONNULL_PTR b); /** * Frees any resources used by the ParseOrSemanticError @@ -34997,12 +42022,12 @@ struct LDKParseOrSemanticError ParseOrSemanticError_clone(const struct LDKParseO /** * Utility method to constructs a new ParseError-variant ParseOrSemanticError */ -struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKParseError a); +struct LDKParseOrSemanticError ParseOrSemanticError_parse_error(struct LDKBolt11ParseError a); /** * Utility method to constructs a new SemanticError-variant ParseOrSemanticError */ -struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKSemanticError a); +struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKBolt11SemanticError a); /** * Checks if two ParseOrSemanticErrors contain equal inner contents. @@ -35011,80 +42036,80 @@ struct LDKParseOrSemanticError ParseOrSemanticError_semantic_error(enum LDKSeman bool ParseOrSemanticError_eq(const struct LDKParseOrSemanticError *NONNULL_PTR a, const struct LDKParseOrSemanticError *NONNULL_PTR b); /** - * Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL. */ -void Invoice_free(struct LDKInvoice this_obj); +void Bolt11Invoice_free(struct LDKBolt11Invoice this_obj); /** - * Checks if two Invoices contain equal inner contents. + * Checks if two Bolt11Invoices 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. */ -bool Invoice_eq(const struct LDKInvoice *NONNULL_PTR a, const struct LDKInvoice *NONNULL_PTR b); +bool Bolt11Invoice_eq(const struct LDKBolt11Invoice *NONNULL_PTR a, const struct LDKBolt11Invoice *NONNULL_PTR b); /** - * Creates a copy of the Invoice + * Creates a copy of the Bolt11Invoice */ -struct LDKInvoice Invoice_clone(const struct LDKInvoice *NONNULL_PTR orig); +struct LDKBolt11Invoice Bolt11Invoice_clone(const struct LDKBolt11Invoice *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Invoice. + * Generates a non-cryptographic 64-bit hash of the Bolt11Invoice. */ -uint64_t Invoice_hash(const struct LDKInvoice *NONNULL_PTR o); +uint64_t Bolt11Invoice_hash(const struct LDKBolt11Invoice *NONNULL_PTR o); /** - * Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL. */ -void SignedRawInvoice_free(struct LDKSignedRawInvoice this_obj); +void SignedRawBolt11Invoice_free(struct LDKSignedRawBolt11Invoice this_obj); /** - * Checks if two SignedRawInvoices contain equal inner contents. + * Checks if two SignedRawBolt11Invoices 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. */ -bool SignedRawInvoice_eq(const struct LDKSignedRawInvoice *NONNULL_PTR a, const struct LDKSignedRawInvoice *NONNULL_PTR b); +bool SignedRawBolt11Invoice_eq(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR a, const struct LDKSignedRawBolt11Invoice *NONNULL_PTR b); /** - * Creates a copy of the SignedRawInvoice + * Creates a copy of the SignedRawBolt11Invoice */ -struct LDKSignedRawInvoice SignedRawInvoice_clone(const struct LDKSignedRawInvoice *NONNULL_PTR orig); +struct LDKSignedRawBolt11Invoice SignedRawBolt11Invoice_clone(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the SignedRawInvoice. + * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice. */ -uint64_t SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR o); +uint64_t SignedRawBolt11Invoice_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); /** - * Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL. */ -void RawInvoice_free(struct LDKRawInvoice this_obj); +void RawBolt11Invoice_free(struct LDKRawBolt11Invoice this_obj); /** * data part */ -struct LDKRawDataPart RawInvoice_get_data(const struct LDKRawInvoice *NONNULL_PTR this_ptr); +struct LDKRawDataPart RawBolt11Invoice_get_data(const struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr); /** * data part */ -void RawInvoice_set_data(struct LDKRawInvoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val); +void RawBolt11Invoice_set_data(struct LDKRawBolt11Invoice *NONNULL_PTR this_ptr, struct LDKRawDataPart val); /** - * Checks if two RawInvoices contain equal inner contents. + * Checks if two RawBolt11Invoices 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. */ -bool RawInvoice_eq(const struct LDKRawInvoice *NONNULL_PTR a, const struct LDKRawInvoice *NONNULL_PTR b); +bool RawBolt11Invoice_eq(const struct LDKRawBolt11Invoice *NONNULL_PTR a, const struct LDKRawBolt11Invoice *NONNULL_PTR b); /** - * Creates a copy of the RawInvoice + * Creates a copy of the RawBolt11Invoice */ -struct LDKRawInvoice RawInvoice_clone(const struct LDKRawInvoice *NONNULL_PTR orig); +struct LDKRawBolt11Invoice RawBolt11Invoice_clone(const struct LDKRawBolt11Invoice *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the RawInvoice. + * Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice. */ -uint64_t RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR o); +uint64_t RawBolt11Invoice_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR o); /** * Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL. @@ -35394,26 +42419,26 @@ uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallback *NONNULL_PTR b); /** - * Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL. */ -void InvoiceSignature_free(struct LDKInvoiceSignature this_obj); +void Bolt11InvoiceSignature_free(struct LDKBolt11InvoiceSignature this_obj); /** - * Creates a copy of the InvoiceSignature + * Creates a copy of the Bolt11InvoiceSignature */ -struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); +struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_clone(const struct LDKBolt11InvoiceSignature *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the InvoiceSignature. + * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature. */ -uint64_t InvoiceSignature_hash(const struct LDKInvoiceSignature *NONNULL_PTR o); +uint64_t Bolt11InvoiceSignature_hash(const struct LDKBolt11InvoiceSignature *NONNULL_PTR o); /** - * Checks if two InvoiceSignatures contain equal inner contents. + * Checks if two Bolt11InvoiceSignatures 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. */ -bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b); +bool Bolt11InvoiceSignature_eq(const struct LDKBolt11InvoiceSignature *NONNULL_PTR a, const struct LDKBolt11InvoiceSignature *NONNULL_PTR b); /** * Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL. @@ -35438,99 +42463,95 @@ uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b); /** - * Disassembles the `SignedRawInvoice` into its three parts: + * Disassembles the `SignedRawBolt11Invoice` into its three parts: * 1. raw invoice * 2. hash of the raw invoice * 3. signature */ -MUST_USE_RES struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ SignedRawInvoice_into_parts(struct LDKSignedRawInvoice this_arg); +MUST_USE_RES struct LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ SignedRawBolt11Invoice_into_parts(struct LDKSignedRawBolt11Invoice this_arg); /** - * The [`RawInvoice`] which was signed. + * The [`RawBolt11Invoice`] which was signed. */ -MUST_USE_RES struct LDKRawInvoice SignedRawInvoice_raw_invoice(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRawBolt11Invoice SignedRawBolt11Invoice_raw_invoice(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * The hash of the [`RawInvoice`] that was signed. + * The hash of the [`RawBolt11Invoice`] that was signed. */ -MUST_USE_RES const uint8_t (*SignedRawInvoice_signable_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32]; +MUST_USE_RES const uint8_t (*SignedRawBolt11Invoice_signable_hash(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg))[32]; /** * Signature for the invoice. */ -MUST_USE_RES struct LDKInvoiceSignature SignedRawInvoice_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceSignature SignedRawBolt11Invoice_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** * Recovers the public key used for signing the invoice from the recoverable signature. */ -MUST_USE_RES struct LDKCResult_PayeePubKeyErrorZ SignedRawInvoice_recover_payee_pub_key(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_PayeePubKeyErrorZ SignedRawBolt11Invoice_recover_payee_pub_key(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** * Checks if the signature is valid for the included payee public key or if none exists if it's * valid for the recovered signature (which should always be true?). */ -MUST_USE_RES bool SignedRawInvoice_check_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES bool SignedRawBolt11Invoice_check_signature(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR this_arg); /** - * Calculate the hash of the encoded `RawInvoice` which should be signed. + * Calculate the hash of the encoded `RawBolt11Invoice` which should be signed. */ -MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_signable_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes RawBolt11Invoice_signable_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKSha256 RawInvoice_payment_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSha256 RawBolt11Invoice_payment_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDescription RawInvoice_description(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDescription RawBolt11Invoice_description(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPayeePubKey RawInvoice_payee_pub_key(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPayeePubKey RawBolt11Invoice_payee_pub_key(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKSha256 RawInvoice_description_hash(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSha256 RawBolt11Invoice_description_hash(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKExpiryTime RawInvoice_expiry_time(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKExpiryTime RawBolt11Invoice_expiry_time(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKMinFinalCltvExpiryDelta RawInvoice_min_final_cltv_expiry_delta(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKMinFinalCltvExpiryDelta RawBolt11Invoice_min_final_cltv_expiry_delta(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); -/** - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_payment_secret(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_PaymentSecretZ RawBolt11Invoice_payment_secret(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); -MUST_USE_RES struct LDKCOption_CVec_u8ZZ RawInvoice_payment_metadata(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ RawBolt11Invoice_payment_metadata(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKInvoiceFeatures RawInvoice_features(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures RawBolt11Invoice_features(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); -MUST_USE_RES struct LDKCVec_PrivateRouteZ RawInvoice_private_routes(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_PrivateRouteZ RawBolt11Invoice_private_routes(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); -MUST_USE_RES struct LDKCOption_u64Z RawInvoice_amount_pico_btc(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z RawBolt11Invoice_amount_pico_btc(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); -MUST_USE_RES enum LDKCurrency RawInvoice_currency(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES enum LDKCurrency RawBolt11Invoice_currency(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); /** * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. @@ -35575,22 +42596,22 @@ MUST_USE_RES uint64_t PositiveTimestamp_as_duration_since_epoch(const struct LDK MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * The hash of the [`RawInvoice`] that was signed. + * The hash of the [`RawBolt11Invoice`] that was signed. */ -MUST_USE_RES struct LDKThirtyTwoBytes Invoice_signable_hash(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt11Invoice_signable_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Transform the `Invoice` into it's unchecked version + * Transform the `Bolt11Invoice` into its unchecked version. */ -MUST_USE_RES struct LDKSignedRawInvoice Invoice_into_signed_raw(struct LDKInvoice this_arg); +MUST_USE_RES struct LDKSignedRawBolt11Invoice Bolt11Invoice_into_signed_raw(struct LDKBolt11Invoice this_arg); /** * Check that the invoice is signed correctly and that key recovery works */ -MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt11SemanticErrorZ Bolt11Invoice_check_signature(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Constructs an `Invoice` from a [`SignedRawInvoice`] by checking all its invariants. + * Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants. * ``` * use lightning_invoice::*; * @@ -35606,120 +42627,120 @@ MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const * 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ * j5r6drg6k6zcqj0fcwg\"; * - * let signed = invoice.parse::().unwrap(); + * let signed = invoice.parse::().unwrap(); * - * assert!(Invoice::from_signed(signed).is_ok()); + * assert!(Bolt11Invoice::from_signed(signed).is_ok()); * ``` */ -MUST_USE_RES struct LDKCResult_InvoiceSemanticErrorZ Invoice_from_signed(struct LDKSignedRawInvoice signed_invoice); +MUST_USE_RES struct LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ Bolt11Invoice_from_signed(struct LDKSignedRawBolt11Invoice signed_invoice); /** - * Returns the `Invoice`'s timestamp (should equal its creation time) + * Returns the `Bolt11Invoice`'s timestamp (should equal its creation time) */ -MUST_USE_RES uint64_t Invoice_timestamp(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_timestamp(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Returns the `Invoice`'s timestamp as a duration since the Unix epoch + * Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch */ -MUST_USE_RES uint64_t Invoice_duration_since_epoch(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_duration_since_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the hash to which we will receive the preimage on completion of the payment */ -MUST_USE_RES const uint8_t (*Invoice_payment_hash(const struct LDKInvoice *NONNULL_PTR this_arg))[32]; +MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_hash(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; /** * Get the payee's public key if one was included in the invoice * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Get the payment secret if one was included in the invoice */ -MUST_USE_RES const uint8_t (*Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg))[32]; +MUST_USE_RES const uint8_t (*Bolt11Invoice_payment_secret(const struct LDKBolt11Invoice *NONNULL_PTR this_arg))[32]; /** * Get the payment metadata blob if one was included in the invoice */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Invoice_payment_metadata(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt11Invoice_payment_metadata(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Get the invoice features if they were included in the invoice * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKInvoiceFeatures Invoice_features(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11Invoice_features(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Recover the payee's public key (only to be used if none was included in the invoice) */ -MUST_USE_RES struct LDKPublicKey Invoice_recover_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_recover_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the Duration since the Unix epoch at which the invoice expires. * Returning None if overflow occurred. */ -MUST_USE_RES struct LDKCOption_DurationZ Invoice_expires_at(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_DurationZ Bolt11Invoice_expires_at(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. */ -MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_expiry_time(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns whether the invoice has expired. */ -MUST_USE_RES bool Invoice_is_expired(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt11Invoice_is_expired(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the Duration remaining until the invoice expires. */ -MUST_USE_RES uint64_t Invoice_duration_until_expiry(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_duration_until_expiry(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the Duration remaining until the invoice expires given the current time. * `time` is the timestamp as a duration since the Unix epoch. */ -MUST_USE_RES uint64_t Invoice_expiration_remaining_from_epoch(const struct LDKInvoice *NONNULL_PTR this_arg, uint64_t time); +MUST_USE_RES uint64_t Bolt11Invoice_expiration_remaining_from_epoch(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t time); /** * Returns whether the expiry time would pass at the given point in time. * `at_time` is the timestamp as a duration since the Unix epoch. */ -MUST_USE_RES bool Invoice_would_expire(const struct LDKInvoice *NONNULL_PTR this_arg, uint64_t at_time); +MUST_USE_RES bool Bolt11Invoice_would_expire(const struct LDKBolt11Invoice *NONNULL_PTR this_arg, uint64_t at_time); /** * Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise * [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`]. */ -MUST_USE_RES uint64_t Invoice_min_final_cltv_expiry_delta(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt11Invoice_min_final_cltv_expiry_delta(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns a list of all fallback addresses as [`Address`]es */ -MUST_USE_RES struct LDKCVec_AddressZ Invoice_fallback_addresses(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_AddressZ Bolt11Invoice_fallback_addresses(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns a list of all routes included in the invoice */ -MUST_USE_RES struct LDKCVec_PrivateRouteZ Invoice_private_routes(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_PrivateRouteZ Bolt11Invoice_private_routes(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns a list of all routes included in the invoice as the underlying hints */ -MUST_USE_RES struct LDKCVec_RouteHintZ Invoice_route_hints(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_RouteHintZ Bolt11Invoice_route_hints(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the currency for which the invoice was issued */ -MUST_USE_RES enum LDKCurrency Invoice_currency(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES enum LDKCurrency Bolt11Invoice_currency(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Returns the amount if specified in the invoice as millisatoshis. */ -MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_milli_satoshis(const struct LDKInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_amount_milli_satoshis(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** * Creates a new `Description` if `description` is at most 1023 __bytes__ long, @@ -35811,70 +42832,70 @@ bool CreationError_eq(const enum LDKCreationError *NONNULL_PTR a, const enum LDK struct LDKStr CreationError_to_str(const enum LDKCreationError *NONNULL_PTR o); /** - * Creates a copy of the SemanticError + * Creates a copy of the Bolt11SemanticError */ -enum LDKSemanticError SemanticError_clone(const enum LDKSemanticError *NONNULL_PTR orig); +enum LDKBolt11SemanticError Bolt11SemanticError_clone(const enum LDKBolt11SemanticError *NONNULL_PTR orig); /** - * Utility method to constructs a new NoPaymentHash-variant SemanticError + * Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_no_payment_hash(void); +enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_hash(void); /** - * Utility method to constructs a new MultiplePaymentHashes-variant SemanticError + * Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_multiple_payment_hashes(void); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_hashes(void); /** - * Utility method to constructs a new NoDescription-variant SemanticError + * Utility method to constructs a new NoDescription-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_no_description(void); +enum LDKBolt11SemanticError Bolt11SemanticError_no_description(void); /** - * Utility method to constructs a new MultipleDescriptions-variant SemanticError + * Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_multiple_descriptions(void); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_descriptions(void); /** - * Utility method to constructs a new NoPaymentSecret-variant SemanticError + * Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_no_payment_secret(void); +enum LDKBolt11SemanticError Bolt11SemanticError_no_payment_secret(void); /** - * Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError + * Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_multiple_payment_secrets(void); +enum LDKBolt11SemanticError Bolt11SemanticError_multiple_payment_secrets(void); /** - * Utility method to constructs a new InvalidFeatures-variant SemanticError + * Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_invalid_features(void); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_features(void); /** - * Utility method to constructs a new InvalidRecoveryId-variant SemanticError + * Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_invalid_recovery_id(void); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_recovery_id(void); /** - * Utility method to constructs a new InvalidSignature-variant SemanticError + * Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_invalid_signature(void); +enum LDKBolt11SemanticError Bolt11SemanticError_invalid_signature(void); /** - * Utility method to constructs a new ImpreciseAmount-variant SemanticError + * Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError */ -enum LDKSemanticError SemanticError_imprecise_amount(void); +enum LDKBolt11SemanticError Bolt11SemanticError_imprecise_amount(void); /** - * Checks if two SemanticErrors contain equal inner contents. + * Checks if two Bolt11SemanticErrors contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool SemanticError_eq(const enum LDKSemanticError *NONNULL_PTR a, const enum LDKSemanticError *NONNULL_PTR b); +bool Bolt11SemanticError_eq(const enum LDKBolt11SemanticError *NONNULL_PTR a, const enum LDKBolt11SemanticError *NONNULL_PTR b); /** - * Get the string representation of a SemanticError object + * Get the string representation of a Bolt11SemanticError object */ -struct LDKStr SemanticError_to_str(const enum LDKSemanticError *NONNULL_PTR o); +struct LDKStr Bolt11SemanticError_to_str(const enum LDKBolt11SemanticError *NONNULL_PTR o); /** * Frees any resources used by the SignOrCreationError @@ -35908,56 +42929,57 @@ bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o); /** - * Pays the given [`Invoice`], retrying if needed based on [`Retry`]. + * Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`]. * - * [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long - * as the payment is still pending. Once the payment completes or fails, you must ensure that - * a second payment with the same [`PaymentHash`] is never sent. + * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long + * as the payment is still pending. If the payment succeeds, you must ensure that a second payment + * with the same [`PaymentHash`] is never sent. * * If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`]. */ -struct LDKCResult_PaymentIdPaymentErrorZ pay_invoice(const struct LDKInvoice *NONNULL_PTR invoice, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); +struct LDKCResult_PaymentIdPaymentErrorZ pay_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); /** - * Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`]. + * Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on + * [`Retry`]. * * Note that idempotency is only guaranteed as long as the payment is still pending. Once the * payment completes or fails, no idempotency guarantees are made. * - * You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] - * has never been paid before. + * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same + * [`PaymentHash`] has never been paid before. * * See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token. */ -struct LDKCResult_NonePaymentErrorZ pay_invoice_with_id(const struct LDKInvoice *NONNULL_PTR invoice, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); +struct LDKCResult_NonePaymentErrorZ pay_invoice_with_id(const struct LDKBolt11Invoice *NONNULL_PTR invoice, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); /** - * Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on + * Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on * [`Retry`]. * - * [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long - * as the payment is still pending. Once the payment completes or fails, you must ensure that - * a second payment with the same [`PaymentHash`] is never sent. + * [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long + * as the payment is still pending. If the payment succeeds, you must ensure that a second payment + * with the same [`PaymentHash`] is never sent. * * If you wish to use a different payment idempotency token, see * [`pay_zero_value_invoice_with_id`]. */ -struct LDKCResult_PaymentIdPaymentErrorZ pay_zero_value_invoice(const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); +struct LDKCResult_PaymentIdPaymentErrorZ pay_zero_value_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msats, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); /** - * Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key, - * , retrying if needed based on [`Retry`]. + * Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key, + * retrying if needed based on [`Retry`]. * * Note that idempotency is only guaranteed as long as the payment is still pending. Once the * payment completes or fails, no idempotency guarantees are made. * - * You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] - * has never been paid before. + * You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same + * [`PaymentHash`] has never been paid before. * * See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the * idempotency token. */ -struct LDKCResult_NonePaymentErrorZ pay_zero_value_invoice_with_id(const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); +struct LDKCResult_NonePaymentErrorZ pay_zero_value_invoice_with_id(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, const struct LDKChannelManager *NONNULL_PTR channelmanager); /** * Frees any resources used by the PaymentError @@ -35979,6 +43001,12 @@ struct LDKPaymentError PaymentError_invoice(struct LDKStr a); */ struct LDKPaymentError PaymentError_sending(enum LDKRetryableSendFailure a); +/** + * Checks if two PaymentErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool PaymentError_eq(const struct LDKPaymentError *NONNULL_PTR a, const struct LDKPaymentError *NONNULL_PTR b); + /** * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" * See [`PhantomKeysManager`] for more information on phantom node payments. @@ -36011,7 +43039,7 @@ struct LDKPaymentError PaymentError_sending(enum LDKRetryableSendFailure a); * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this * requirement). * - * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager + * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -36020,10 +43048,8 @@ struct LDKPaymentError PaymentError_sending(enum LDKRetryableSendFailure a); * * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. - * - * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKThirtyTwoBytes payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_PaymentHashZ payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" @@ -36035,9 +43061,11 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC * participating node * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is * updated when a channel becomes disabled or closes - * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice - * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared - * down + * * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum + * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected + * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node + * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as + * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. * * `description_hash` is a SHA-256 hash of the description text * @@ -36054,7 +43082,7 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this * requirement). * - * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager + * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -36062,10 +43090,8 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC * * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. - * - * Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_PaymentHashZ payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** * Utility to construct an invoice. Generally, unless you want to do something like a custom @@ -36084,7 +43110,7 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_descri * * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** * Utility to construct an invoice. Generally, unless you want to do something like a custom @@ -36104,21 +43130,21 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager * * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** * See [`create_invoice_from_channelmanager_with_description_hash`] * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** * See [`create_invoice_from_channelmanager`] * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not * available and the current time is supplied by the caller. */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** * See [`create_invoice_from_channelmanager_and_duration_since_epoch`] @@ -36126,27 +43152,27 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager * This may be useful if you're building an on-chain swap or involving another protocol where * the payment hash is also involved outside the scope of lightning. */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** * Read a SiPrefix object from a string */ -struct LDKCResult_SiPrefixParseErrorZ SiPrefix_from_str(struct LDKStr s); +struct LDKCResult_SiPrefixBolt11ParseErrorZ SiPrefix_from_str(struct LDKStr s); /** - * Read a Invoice object from a string + * Read a Bolt11Invoice object from a string */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ Invoice_from_str(struct LDKStr s); +struct LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ Bolt11Invoice_from_str(struct LDKStr s); /** - * Read a SignedRawInvoice object from a string + * Read a SignedRawBolt11Invoice object from a string */ -struct LDKCResult_SignedRawInvoiceParseErrorZ SignedRawInvoice_from_str(struct LDKStr s); +struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ SignedRawBolt11Invoice_from_str(struct LDKStr s); /** - * Get the string representation of a ParseError object + * Get the string representation of a Bolt11ParseError object */ -struct LDKStr ParseError_to_str(const struct LDKParseError *NONNULL_PTR o); +struct LDKStr Bolt11ParseError_to_str(const struct LDKBolt11ParseError *NONNULL_PTR o); /** * Get the string representation of a ParseOrSemanticError object @@ -36154,14 +43180,14 @@ struct LDKStr ParseError_to_str(const struct LDKParseError *NONNULL_PTR o); struct LDKStr ParseOrSemanticError_to_str(const struct LDKParseOrSemanticError *NONNULL_PTR o); /** - * Get the string representation of a Invoice object + * Get the string representation of a Bolt11Invoice object */ -struct LDKStr Invoice_to_str(const struct LDKInvoice *NONNULL_PTR o); +struct LDKStr Bolt11Invoice_to_str(const struct LDKBolt11Invoice *NONNULL_PTR o); /** - * Get the string representation of a SignedRawInvoice object + * Get the string representation of a SignedRawBolt11Invoice object */ -struct LDKStr SignedRawInvoice_to_str(const struct LDKSignedRawInvoice *NONNULL_PTR o); +struct LDKStr SignedRawBolt11Invoice_to_str(const struct LDKSignedRawBolt11Invoice *NONNULL_PTR o); /** * Get the string representation of a Currency object @@ -36183,6 +43209,25 @@ void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); */ MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +/** + * Sync gossip data from a file. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `network_graph`: The network graph to apply the updates to + * + * `sync_path`: Path to the file where the gossip update data is located + * + */ +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_graph_with_file_path(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKStr sync_path); + +/** + * Update network graph from binary data. + * Returns the last sync timestamp to be used the next time rapid sync data is queried. + * + * `update_data`: `&[u8]` binary stream that comprises the update data + */ +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data); + /** * Update network graph from binary data. * Returns the last sync timestamp to be used the next time rapid sync data is queried. diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index c4ef0ea..15be15d 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -7,24 +7,22 @@ class Retry; class RetryableSendFailure; class PaymentSendFailure; class RecipientOnionFields; -class HTLCClaim; -class CounterpartyCommitmentSecrets; -class TxCreationKeys; -class ChannelPublicKeys; -class HTLCOutputInCommitment; -class ChannelTransactionParameters; -class CounterpartyChannelTransactionParameters; -class DirectedChannelTransactionParameters; -class HolderCommitmentTransaction; -class BuiltCommitmentTransaction; -class ClosingTransaction; -class TrustedClosingTransaction; -class CommitmentTransaction; -class TrustedCommitmentTransaction; -class ShutdownScript; -class InvalidShutdownScript; -class UnsignedInvoice; +class UnsignedBolt12Invoice; +class Bolt12Invoice; class BlindedPayInfo; +class DelayedPaymentOutputDescriptor; +class StaticPaymentOutputDescriptor; +class SpendableOutputDescriptor; +class ChannelSigner; +class EcdsaChannelSigner; +class WriteableEcdsaChannelSigner; +class Recipient; +class EntropySource; +class NodeSigner; +class SignerProvider; +class InMemorySigner; +class KeysManager; +class PhantomKeysManager; class BackgroundProcessor; class GossipSync; class DefaultRouter; @@ -37,19 +35,9 @@ class Path; class Route; class RouteParameters; class PaymentParameters; -class Hints; +class Payee; class RouteHint; class RouteHintHop; -class BroadcasterInterface; -class ConfirmationTarget; -class FeeEstimator; -class BestBlock; -class Listen; -class Confirm; -class ChannelMonitorUpdateStatus; -class Watch; -class Filter; -class WatchedOutput; class Score; class LockableScore; class WriteableScore; @@ -58,29 +46,24 @@ class MultiThreadedScoreLock; class ChannelUsage; class FixedPenaltyScorer; class ProbabilisticScorer; -class ProbabilisticScoringParameters; -class OnionMessageContents; -class CustomOnionMessageContents; +class ProbabilisticScoringFeeParameters; +class ProbabilisticScoringDecayParameters; +class BestBlock; +class Listen; +class Confirm; +class ChannelMonitorUpdateStatus; +class Watch; +class Filter; +class WatchedOutput; class InitFeatures; class NodeFeatures; class ChannelFeatures; -class InvoiceFeatures; +class Bolt11InvoiceFeatures; class OfferFeatures; class InvoiceRequestFeatures; class Bolt12InvoiceFeatures; class BlindedHopFeatures; class ChannelTypeFeatures; -class PaymentPurpose; -class PathFailure; -class ClosureReason; -class HTLCDestination; -class PaymentFailureReason; -class Event; -class MessageSendEvent; -class MessageSendEventsProvider; -class OnionMessageProvider; -class EventsProvider; -class EventHandler; class Offer; class Amount; class Quantity; @@ -97,42 +80,34 @@ class RoutingFees; class NodeAnnouncementInfo; class NodeAlias; class NodeInfo; -class DelayedPaymentOutputDescriptor; -class StaticPaymentOutputDescriptor; -class SpendableOutputDescriptor; -class ChannelSigner; -class EcdsaChannelSigner; -class WriteableEcdsaChannelSigner; -class Recipient; -class EntropySource; -class NodeSigner; -class SignerProvider; -class InMemorySigner; -class KeysManager; -class PhantomKeysManager; -class FilesystemPersister; +class ChannelDerivationParameters; +class AnchorDescriptor; +class HTLCDescriptor; +class BumpTransactionEvent; +class Input; +class Utxo; +class CoinSelection; +class CoinSelectionSource; +class WalletSource; +class Wallet; +class BumpTransactionEventHandler; class FailureCode; class ChannelManager; class ChainParameters; class CounterpartyForwardingInfo; class ChannelCounterparty; class ChannelDetails; +class ChannelShutdownState; class RecentPaymentDetails; class PhantomRouteHints; class ChannelManagerReadArgs; class ChannelHandshakeConfig; class ChannelHandshakeLimits; +class MaxDustHTLCExposure; class ChannelConfig; +class ChannelConfigUpdate; class UserConfig; class APIError; -class BigSize; -class Hostname; -class UntrustedString; -class PrintableString; -class OutPoint; -class CustomMessageReader; -class Type; -class PaymentError; class ChannelMonitorUpdate; class MonitorEvent; class HTLCUpdate; @@ -146,37 +121,10 @@ class MessageHandler; class SocketDescriptor; class PeerHandleError; class PeerManager; -class UtxoLookupError; -class UtxoResult; -class UtxoLookup; -class UtxoFuture; -class OnionMessenger; -class Destination; -class SendError; -class CustomOnionMessageHandler; -class BlindedPath; -class BlindedHop; -class ParseError; -class ParseOrSemanticError; -class Invoice; -class SignedRawInvoice; -class RawInvoice; -class RawDataPart; -class PositiveTimestamp; -class SiPrefix; -class Currency; -class Sha256; -class Description; -class PayeePubKey; -class ExpiryTime; -class MinFinalCltvExpiryDelta; -class Fallback; -class InvoiceSignature; -class PrivateRoute; -class CreationError; -class SemanticError; -class SignOrCreationError; +class RapidGossipSync; class Persister; +class UnsignedInvoiceRequest; +class InvoiceRequest; class DecodeError; class Init; class ErrorMessage; @@ -184,10 +132,21 @@ class WarningMessage; class Ping; class Pong; class OpenChannel; +class OpenChannelV2; class AcceptChannel; +class AcceptChannelV2; class FundingCreated; class FundingSigned; class ChannelReady; +class TxAddInput; +class TxAddOutput; +class TxRemoveInput; +class TxRemoveOutput; +class TxComplete; +class TxSignatures; +class TxInitRbf; +class TxAckRbf; +class TxAbort; class Shutdown; class ClosingSignedFeeRange; class ClosingSigned; @@ -199,7 +158,6 @@ class UpdateFailMalformedHTLC; class CommitmentSigned; class RevokeAndACK; class UpdateFee; -class DataLossProtect; class ChannelReestablish; class AnnouncementSignatures; class NetAddress; @@ -221,71 +179,162 @@ class CommitmentUpdate; class ChannelMessageHandler; class RoutingMessageHandler; class OnionMessageHandler; -class UnsignedInvoiceRequest; -class InvoiceRequest; class Level; class Record; class Logger; class FutureCallback; class Future; class Sleeper; +class OffersMessageHandler; +class OffersMessage; +class HTLCClaim; +class CounterpartyCommitmentSecrets; +class TxCreationKeys; +class ChannelPublicKeys; +class HTLCOutputInCommitment; +class ChannelTransactionParameters; +class CounterpartyChannelTransactionParameters; +class DirectedChannelTransactionParameters; +class HolderCommitmentTransaction; +class BuiltCommitmentTransaction; +class ClosingTransaction; +class TrustedClosingTransaction; +class CommitmentTransaction; +class TrustedCommitmentTransaction; +class ShutdownScript; +class InvalidShutdownScript; +class Bolt12ParseError; +class Bolt12SemanticError; +class BroadcasterInterface; +class ConfirmationTarget; +class FeeEstimator; +class OnionMessageContents; +class CustomOnionMessageContents; +class PaymentPurpose; +class PathFailure; +class ClosureReason; +class HTLCDestination; +class PaymentFailureReason; +class Event; +class MessageSendEvent; +class MessageSendEventsProvider; +class OnionMessageProvider; +class EventsProvider; +class EventHandler; +class FilesystemPersister; +class Bolt11ParseError; +class ParseOrSemanticError; +class Bolt11Invoice; +class SignedRawBolt11Invoice; +class RawBolt11Invoice; +class RawDataPart; +class PositiveTimestamp; +class SiPrefix; +class Currency; +class Sha256; +class Description; +class PayeePubKey; +class ExpiryTime; +class MinFinalCltvExpiryDelta; +class Fallback; +class Bolt11InvoiceSignature; +class PrivateRoute; +class CreationError; +class Bolt11SemanticError; +class SignOrCreationError; +class OutPoint; +class BigSize; +class Hostname; +class TransactionU16LenLimited; +class UntrustedString; +class PrintableString; +class CustomMessageReader; +class Type; +class PaymentError; +class UtxoLookupError; +class UtxoResult; +class UtxoLookup; +class UtxoFuture; +class OnionMessenger; +class MessageRouter; +class DefaultMessageRouter; +class OnionMessagePath; +class Destination; +class SendError; +class CustomOnionMessageHandler; +class BlindedPath; +class BlindedHop; +class GraphSyncError; +class InvoiceError; +class ErroneousField; class MonitorUpdateId; class Persist; class LockedChannelMonitor; class ChainMonitor; -class GraphSyncError; -class RapidGossipSync; class CResult_LockedChannelMonitorNoneZ; +class CResult_TransactionU16LenLimitedNoneZ; class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ; class CResult_PhantomRouteHintsDecodeErrorZ; -class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; +class CResult_FundingCreatedDecodeErrorZ; class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; class CVec_C2Tuple_u32TxOutZZ; -class CResult_FundingCreatedDecodeErrorZ; +class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; +class COption_PaymentSecretZ; class CResult_ChannelInfoDecodeErrorZ; +class COption_MaxDustHTLCExposureZ; class CResult_NoneSendErrorZ; +class COption_OffersMessageZ; class CResult_CVec_u8ZPeerHandleErrorZ; -class CResult_GossipTimestampFilterDecodeErrorZ; class COption_NetworkUpdateZ; class COption_u64Z; +class CResult_GossipTimestampFilterDecodeErrorZ; class CResult_PaymentPreimageAPIErrorZ; class CResult_RouteHintDecodeErrorZ; class COption_FilterZ; class COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; class CResult_COption_APIErrorZDecodeErrorZ; class CVec_UpdateAddHTLCZ; -class CResult_CommitmentSignedDecodeErrorZ; -class COption_u32Z; +class CResult_TxAbortDecodeErrorZ; class CResult_StaticPaymentOutputDescriptorDecodeErrorZ; -class CVec_C2Tuple_TxidBlockHashZZ; -class CResult_CommitmentTransactionDecodeErrorZ; -class CResult_TransactionNoneZ; +class COption_u32Z; +class CResult_CommitmentSignedDecodeErrorZ; class CResult_ClosingSignedFeeRangeDecodeErrorZ; +class CResult_TransactionNoneZ; +class CResult_CommitmentTransactionDecodeErrorZ; class COption_DurationZ; -class CResult_ErrorMessageDecodeErrorZ; +class C2Tuple_TxidCOption_BlockHashZZ; +class COption_PaymentHashZ; class CResult_OpenChannelDecodeErrorZ; +class CResult_ErrorMessageDecodeErrorZ; class COption_APIErrorZ; class CResult_QueryChannelRangeDecodeErrorZ; class CVec_TransactionZ; -class C2Tuple_TxidBlockHashZ; +class CVec_InputZ; +class CResult_PartiallySignedTransactionNoneZ; class CResult_ChannelFeaturesDecodeErrorZ; class CResult_ChannelReadyDecodeErrorZ; class CResult_UpdateFeeDecodeErrorZ; -class CResult_HTLCOutputInCommitmentDecodeErrorZ; -class CResult_boolLightningErrorZ; +class CResult_NoneBolt11SemanticErrorZ; +class CResult_NoneRetryableSendFailureZ; +class COption_BlockHashZ; class CResult_NodeIdDecodeErrorZ; -class COption_HTLCDestinationZ; -class C2Tuple_BlockHashChannelMonitorZ; -class CResult_ShutdownScriptInvalidShutdownScriptZ; +class CResult_boolLightningErrorZ; +class CResult_ChannelShutdownStateDecodeErrorZ; class CResult_NodeAnnouncementInfoDecodeErrorZ; +class C2Tuple_BlockHashChannelMonitorZ; class CResult_COption_NetworkUpdateZDecodeErrorZ; -class CResult_NoneRetryableSendFailureZ; class CVec_UpdateFailMalformedHTLCZ; -class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; +class CResult_ShutdownScriptNoneZ; +class CResult_HTLCOutputInCommitmentDecodeErrorZ; +class CResult_ShutdownScriptInvalidShutdownScriptZ; class CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ; +class COption_HTLCDestinationZ; +class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; class CVec_RouteHopZ; +class CResult_CVec_UtxoZNoneZ; class COption_CustomOnionMessageContentsZ; class CVec_C2Tuple_BlockHashChannelMonitorZZ; +class CResult_COption_KeyPairZNoneZ; class CVec_ThirtyTwoBytesZ; class CResult_ClosingSignedDecodeErrorZ; class CResult_NonePaymentErrorZ; @@ -295,8 +344,10 @@ class CVec_RecentPaymentDetailsZ; class CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; class CVec_RouteHintHopZ; class CResult_UntrustedStringDecodeErrorZ; -class CResult_PaymentParametersDecodeErrorZ; class CVec_U5Z; +class CResult_PaymentParametersDecodeErrorZ; +class CResult_TxAckRbfDecodeErrorZ; +class CResult_Bolt11InvoiceBolt11SemanticErrorZ; class COption_UtxoLookupZ; class CResult_PongDecodeErrorZ; class CResult_UnsignedChannelAnnouncementDecodeErrorZ; @@ -307,47 +358,47 @@ class CResult_ChannelTransactionParametersDecodeErrorZ; class CResult_WriteableEcdsaChannelSignerDecodeErrorZ; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ; class C2Tuple_PaymentHashPaymentIdZ; -class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; class CResult_NoneErrorZ; class CResult_InFlightHtlcsDecodeErrorZ; class CResult_COption_HTLCDestinationZDecodeErrorZ; -class CResult_SiPrefixParseErrorZ; +class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ; class CResult_BlindedHopDecodeErrorZ; -class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_NoneLightningErrorZ; class CResult_FixedPenaltyScorerDecodeErrorZ; class CVec_BlindedPathZ; -class CResult_NoneLightningErrorZ; class CResult_PaymentHashRetryableSendFailureZ; -class CResult_COption_EventZDecodeErrorZ; -class CResult_CVec_SignatureZNoneZ; +class C2Tuple_PublicKeyCOption_NetAddressZZ; class COption_CVec_NetAddressZZ; +class CResult_NonePeerHandleErrorZ; +class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_CVec_SignatureZNoneZ; class CResult_PaymentFailureReasonDecodeErrorZ; -class C2Tuple_PublicKeyCOption_NetAddressZZ; class CResult__u832APIErrorZ; -class CResult_PaymentIdPaymentErrorZ; class CResult_COption_MonitorEventZDecodeErrorZ; +class CResult_COption_EventZDecodeErrorZ; class CResult_RoutingFeesDecodeErrorZ; -class CResult_NonePeerHandleErrorZ; class CResult_PayeePubKeyErrorZ; class CResult_DescriptionCreationErrorZ; +class CResult_PaymentIdPaymentErrorZ; class CResult_QueryShortChannelIdsDecodeErrorZ; -class CResult_InvoiceSemanticErrorZ; class CResult_UpdateAddHTLCDecodeErrorZ; class COption_MonitorEventZ; +class COption_CVec_ChainHashZZ; class COption_TypeZ; class CResult_COption_TypeZDecodeErrorZ; -class CResult_COption_PathFailureZDecodeErrorZ; +class COption_KeyPairZ; +class CResult_Bolt11InvoiceSignOrCreationErrorZ; +class COption_ScriptZ; class CResult_UpdateFailHTLCDecodeErrorZ; -class CResult_InvoiceParseOrSemanticErrorZ; +class CResult_COption_PathFailureZDecodeErrorZ; class CResult_RevokeAndACKDecodeErrorZ; class CResult_SpendableOutputDescriptorDecodeErrorZ; class CResult_UnsignedChannelUpdateDecodeErrorZ; -class CVec_EventZ; -class CResult_NoneSemanticErrorZ; class CVec_C2Tuple_u32ScriptZZ; +class CResult_InvoiceErrorDecodeErrorZ; class CVec_BlindedHopZ; -class CResult_COption_ClosureReasonZDecodeErrorZ; class CResult_PaymentHashPaymentSendFailureZ; +class CResult_COption_ClosureReasonZDecodeErrorZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; class CResult_RouteParametersDecodeErrorZ; class CResult_PrivateRouteCreationErrorZ; @@ -355,66 +406,80 @@ class CResult_NodeAliasDecodeErrorZ; class CVec_UpdateFulfillHTLCZ; class CResult_AnnouncementSignaturesDecodeErrorZ; class CResult_UpdateFulfillHTLCDecodeErrorZ; +class CResult_TxCompleteDecodeErrorZ; class CResult_NodeFeaturesDecodeErrorZ; class CResult_InMemorySignerDecodeErrorZ; +class CResult_TxSignaturesDecodeErrorZ; +class CVec_HTLCDescriptorZ; class CResult_ReplyShortChannelIdsEndDecodeErrorZ; -class COption_PathFailureZ; class COption_ScalarZ; +class COption_PathFailureZ; class CResult_ChannelUpdateInfoDecodeErrorZ; -class CResult_BuiltCommitmentTransactionDecodeErrorZ; class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; -class CVec_TxOutZ; class CVec_UpdateFailHTLCZ; +class CVec_TxOutZ; +class CResult_BuiltCommitmentTransactionDecodeErrorZ; class CVec_SpendableOutputDescriptorZ; class COption_C2Tuple_u64u64ZZ; class CResult_ChannelAnnouncementDecodeErrorZ; class CResult_HTLCUpdateDecodeErrorZ; class C2Tuple_SignatureCVec_SignatureZZ; -class CVec_OutPointZ; +class C2Tuple_PartiallySignedTransactionusizeZ; +class CResult_TxAddInputDecodeErrorZ; class COption_WriteableScoreZ; +class CResult_TxInitRbfDecodeErrorZ; +class CVec_OutPointZ; class CResult_PositiveTimestampCreationErrorZ; class C2Tuple__u168_u168Z; -class CResult_InvoiceFeaturesDecodeErrorZ; -class C2Tuple_BlindedPayInfoBlindedPathZ; class CResult_ChannelMonitorUpdateDecodeErrorZ; +class C2Tuple_BlindedPayInfoBlindedPathZ; class CResult_ReplyChannelRangeDecodeErrorZ; -class CResult_TrustedClosingTransactionNoneZ; +class COption_PaymentPreimageZ; class CResult_NetAddressDecodeErrorZ; +class CResult_UnsignedNodeAnnouncementDecodeErrorZ; class C2Tuple_PublicKeyTypeZ; +class CResult_TxRemoveOutputDecodeErrorZ; class CResult_ChannelReestablishDecodeErrorZ; +class CResult_ScriptNoneZ; class CResult_OnionMessageDecodeErrorZ; -class CResult_UnsignedNodeAnnouncementDecodeErrorZ; -class CResult_InvoiceSignOrCreationErrorZ; +class CResult_TrustedClosingTransactionNoneZ; +class CResult_Bolt11InvoiceParseOrSemanticErrorZ; class CResult_InitFeaturesDecodeErrorZ; class CResult_PublicKeyNoneZ; class CResult_PingDecodeErrorZ; class CResult_BlindedHopFeaturesDecodeErrorZ; +class COption_PackedLockTimeZ; class CVec_TransactionOutputsZ; class COption_HTLCClaimZ; class CVec_CVec_u8ZZ; class CResult_COption_CustomOnionMessageContentsZDecodeErrorZ; -class CResult_ShutdownScriptDecodeErrorZ; class CResult_ProbabilisticScorerDecodeErrorZ; +class CResult_ShutdownScriptDecodeErrorZ; +class CResult_SiPrefixBolt11ParseErrorZ; class C2Tuple_usizeTransactionZ; -class CResult_TxCreationKeysDecodeErrorZ; class CResult_NodeAnnouncementDecodeErrorZ; -class CVec_ChannelMonitorZ; -class CResult_BlindedPathDecodeErrorZ; class CVec_FutureZ; +class CVec_ChannelMonitorZ; +class CResult_AcceptChannelV2DecodeErrorZ; +class CResult_TxCreationKeysDecodeErrorZ; class CResult_RouteHopDecodeErrorZ; +class CVec_HTLCOutputInCommitmentZ; +class CResult_CoinSelectionNoneZ; +class CResult_BlindedPathDecodeErrorZ; class CVec_BalanceZ; +class CResult_MaxDustHTLCExposureDecodeErrorZ; class CResult_FundingSignedDecodeErrorZ; class CResult_RecoverableSignatureNoneZ; class C2Tuple_Z; -class C3Tuple_RawInvoice_u832InvoiceSignatureZ; class CVec_PathZ; class CResult_NetworkGraphDecodeErrorZ; class CResult_NodeInfoDecodeErrorZ; class CVec_NodeIdZ; class CVec_u8Z; -class CResult_ChannelPublicKeysDecodeErrorZ; class CResult_RouteLightningErrorZ; class CResult_NonePaymentSendFailureZ; +class CResult_ChannelPublicKeysDecodeErrorZ; +class CVec_C2Tuple_TxidCOption_BlockHashZZZ; class CResult_HolderCommitmentTransactionDecodeErrorZ; class CResult_WarningMessageDecodeErrorZ; class CResult_ChannelCounterpartyDecodeErrorZ; @@ -425,17 +490,21 @@ class CVec_MonitorUpdateIdZ; class CResult_PaymentPurposeDecodeErrorZ; class CResult_OutPointDecodeErrorZ; class CVec_ChannelDetailsZ; +class CResult_Bolt11InvoiceFeaturesDecodeErrorZ; class CVec_MessageSendEventZ; class COption_NetAddressZ; class C2Tuple_OutPointScriptZ; class CResult_RouteHintHopDecodeErrorZ; class CResult_UpdateFailMalformedHTLCDecodeErrorZ; class CResult_BlindedPayInfoDecodeErrorZ; +class COption_ChannelShutdownStateZ; +class CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ; class CResult_SharedSecretNoneZ; class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; class CResult_CVec_CVec_u8ZZNoneZ; class C2Tuple_PaymentHashPaymentSecretZ; class CResult_AcceptChannelDecodeErrorZ; +class CResult_HostnameDecodeErrorZ; class CVec_SignatureZ; class CVec_u64Z; class CResult_StringErrorZ; @@ -443,48 +512,63 @@ class C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; class CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; class COption_EventZ; class CResult_ChannelTypeFeaturesDecodeErrorZ; +class COption_TxidZ; class CVec_RouteHintZ; -class COption_PaymentFailureReasonZ; class COption_u16Z; +class COption_PaymentFailureReasonZ; class CVec_ChainHashZ; +class CVec_WitnessZ; class CResult_BlindedTailDecodeErrorZ; +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; class CVec_C2Tuple_PublicKeyTypeZZ; +class CResult_OnionMessagePathNoneZ; +class CResult_RefundBolt12ParseErrorZ; class C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; class CResult_u32GraphSyncErrorZ; class CVec_PhantomRouteHintsZ; +class CResult_OffersMessageDecodeErrorZ; class CResult_NoneAPIErrorZ; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; +class CResult_Bolt12InvoiceFeaturesDecodeErrorZ; class CVec_NetAddressZ; class CResult_ChannelDetailsDecodeErrorZ; -class CVec_C2Tuple_usizeTransactionZZ; class CVec_PublicKeyZ; +class CVec_C2Tuple_usizeTransactionZZ; +class CResult_TxRemoveInputDecodeErrorZ; +class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; +class COption_PaymentIdZ; class C2Tuple_u64u64Z; class CResult_RecipientOnionFieldsDecodeErrorZ; class C2Tuple_u32TxOutZ; +class CVec_UtxoZ; class CResult_PaymentSecretNoneZ; class CResult_ChannelConfigDecodeErrorZ; class CVec_PrivateRouteZ; +class COption_i64Z; class CResult_BlindedPathNoneZ; class CResult_ShutdownDecodeErrorZ; +class CResult_OfferBolt12ParseErrorZ; class CResult_TxOutUtxoLookupErrorZ; class CVec_MonitorEventZ; class CVec_PaymentPreimageZ; +class CResult_BigSizeDecodeErrorZ; class CResult_PublicKeyErrorZ; class CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; class CResult_NoneNoneZ; +class CResult_boolPeerHandleErrorZ; +class CResult_ChannelUpdateDecodeErrorZ; +class CVec_APIErrorZ; +class COption_TxOutZ; class COption_ClosureReasonZ; class COption_u128Z; -class CVec_APIErrorZ; -class CResult_boolPeerHandleErrorZ; class CVec_AddressZ; -class CResult_ChannelUpdateDecodeErrorZ; -class CResult_PaymentSecretAPIErrorZ; +class CResult_TransactionU16LenLimitedDecodeErrorZ; class CResult_CounterpartyForwardingInfoDecodeErrorZ; +class CResult_OpenChannelV2DecodeErrorZ; class C2Tuple_u32ScriptZ; -class CResult_SignedRawInvoiceParseErrorZ; class COption_C2Tuple_EightU16sEightU16sZZ; class CResult_RouteDecodeErrorZ; class COption_NoneZ; +class CResult_TxAddOutputDecodeErrorZ; class COption_CVec_u8ZZ; class Str { @@ -576,259 +660,35 @@ public: const LDKRecipientOnionFields* operator &() const { return &self; } const LDKRecipientOnionFields* operator ->() const { return &self; } }; -class HTLCClaim { -private: - LDKHTLCClaim self; -public: - HTLCClaim(const HTLCClaim&) = delete; - HTLCClaim(HTLCClaim&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCClaim)); } - HTLCClaim(LDKHTLCClaim&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCClaim)); } - operator LDKHTLCClaim() && { LDKHTLCClaim res = self; memset(&self, 0, sizeof(LDKHTLCClaim)); return res; } - HTLCClaim& operator=(HTLCClaim&& o) { self = o.self; memset(&o, 0, sizeof(HTLCClaim)); return *this; } - LDKHTLCClaim* operator &() { return &self; } - LDKHTLCClaim* operator ->() { return &self; } - const LDKHTLCClaim* operator &() const { return &self; } - const LDKHTLCClaim* operator ->() const { return &self; } -}; -class CounterpartyCommitmentSecrets { -private: - LDKCounterpartyCommitmentSecrets self; -public: - CounterpartyCommitmentSecrets(const CounterpartyCommitmentSecrets&) = delete; - CounterpartyCommitmentSecrets(CounterpartyCommitmentSecrets&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); } - CounterpartyCommitmentSecrets(LDKCounterpartyCommitmentSecrets&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); } - operator LDKCounterpartyCommitmentSecrets() && { LDKCounterpartyCommitmentSecrets res = self; memset(&self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); return res; } - ~CounterpartyCommitmentSecrets() { CounterpartyCommitmentSecrets_free(self); } - CounterpartyCommitmentSecrets& operator=(CounterpartyCommitmentSecrets&& o) { CounterpartyCommitmentSecrets_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); return *this; } - LDKCounterpartyCommitmentSecrets* operator &() { return &self; } - LDKCounterpartyCommitmentSecrets* operator ->() { return &self; } - const LDKCounterpartyCommitmentSecrets* operator &() const { return &self; } - const LDKCounterpartyCommitmentSecrets* operator ->() const { return &self; } -}; -class TxCreationKeys { -private: - LDKTxCreationKeys self; -public: - TxCreationKeys(const TxCreationKeys&) = delete; - TxCreationKeys(TxCreationKeys&& o) : self(o.self) { memset(&o, 0, sizeof(TxCreationKeys)); } - TxCreationKeys(LDKTxCreationKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxCreationKeys)); } - operator LDKTxCreationKeys() && { LDKTxCreationKeys res = self; memset(&self, 0, sizeof(LDKTxCreationKeys)); return res; } - ~TxCreationKeys() { TxCreationKeys_free(self); } - TxCreationKeys& operator=(TxCreationKeys&& o) { TxCreationKeys_free(self); self = o.self; memset(&o, 0, sizeof(TxCreationKeys)); return *this; } - LDKTxCreationKeys* operator &() { return &self; } - LDKTxCreationKeys* operator ->() { return &self; } - const LDKTxCreationKeys* operator &() const { return &self; } - const LDKTxCreationKeys* operator ->() const { return &self; } -}; -class ChannelPublicKeys { -private: - LDKChannelPublicKeys self; -public: - ChannelPublicKeys(const ChannelPublicKeys&) = delete; - ChannelPublicKeys(ChannelPublicKeys&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelPublicKeys)); } - ChannelPublicKeys(LDKChannelPublicKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelPublicKeys)); } - operator LDKChannelPublicKeys() && { LDKChannelPublicKeys res = self; memset(&self, 0, sizeof(LDKChannelPublicKeys)); return res; } - ~ChannelPublicKeys() { ChannelPublicKeys_free(self); } - ChannelPublicKeys& operator=(ChannelPublicKeys&& o) { ChannelPublicKeys_free(self); self = o.self; memset(&o, 0, sizeof(ChannelPublicKeys)); return *this; } - LDKChannelPublicKeys* operator &() { return &self; } - LDKChannelPublicKeys* operator ->() { return &self; } - const LDKChannelPublicKeys* operator &() const { return &self; } - const LDKChannelPublicKeys* operator ->() const { return &self; } -}; -class HTLCOutputInCommitment { -private: - LDKHTLCOutputInCommitment self; -public: - HTLCOutputInCommitment(const HTLCOutputInCommitment&) = delete; - HTLCOutputInCommitment(HTLCOutputInCommitment&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCOutputInCommitment)); } - HTLCOutputInCommitment(LDKHTLCOutputInCommitment&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCOutputInCommitment)); } - operator LDKHTLCOutputInCommitment() && { LDKHTLCOutputInCommitment res = self; memset(&self, 0, sizeof(LDKHTLCOutputInCommitment)); return res; } - ~HTLCOutputInCommitment() { HTLCOutputInCommitment_free(self); } - HTLCOutputInCommitment& operator=(HTLCOutputInCommitment&& o) { HTLCOutputInCommitment_free(self); self = o.self; memset(&o, 0, sizeof(HTLCOutputInCommitment)); return *this; } - LDKHTLCOutputInCommitment* operator &() { return &self; } - LDKHTLCOutputInCommitment* operator ->() { return &self; } - const LDKHTLCOutputInCommitment* operator &() const { return &self; } - const LDKHTLCOutputInCommitment* operator ->() const { return &self; } -}; -class ChannelTransactionParameters { -private: - LDKChannelTransactionParameters self; -public: - ChannelTransactionParameters(const ChannelTransactionParameters&) = delete; - ChannelTransactionParameters(ChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTransactionParameters)); } - ChannelTransactionParameters(LDKChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTransactionParameters)); } - operator LDKChannelTransactionParameters() && { LDKChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKChannelTransactionParameters)); return res; } - ~ChannelTransactionParameters() { ChannelTransactionParameters_free(self); } - ChannelTransactionParameters& operator=(ChannelTransactionParameters&& o) { ChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTransactionParameters)); return *this; } - LDKChannelTransactionParameters* operator &() { return &self; } - LDKChannelTransactionParameters* operator ->() { return &self; } - const LDKChannelTransactionParameters* operator &() const { return &self; } - const LDKChannelTransactionParameters* operator ->() const { return &self; } -}; -class CounterpartyChannelTransactionParameters { -private: - LDKCounterpartyChannelTransactionParameters self; -public: - CounterpartyChannelTransactionParameters(const CounterpartyChannelTransactionParameters&) = delete; - CounterpartyChannelTransactionParameters(CounterpartyChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyChannelTransactionParameters)); } - CounterpartyChannelTransactionParameters(LDKCounterpartyChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); } - operator LDKCounterpartyChannelTransactionParameters() && { LDKCounterpartyChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); return res; } - ~CounterpartyChannelTransactionParameters() { CounterpartyChannelTransactionParameters_free(self); } - CounterpartyChannelTransactionParameters& operator=(CounterpartyChannelTransactionParameters&& o) { CounterpartyChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyChannelTransactionParameters)); return *this; } - LDKCounterpartyChannelTransactionParameters* operator &() { return &self; } - LDKCounterpartyChannelTransactionParameters* operator ->() { return &self; } - const LDKCounterpartyChannelTransactionParameters* operator &() const { return &self; } - const LDKCounterpartyChannelTransactionParameters* operator ->() const { return &self; } -}; -class DirectedChannelTransactionParameters { -private: - LDKDirectedChannelTransactionParameters self; -public: - DirectedChannelTransactionParameters(const DirectedChannelTransactionParameters&) = delete; - DirectedChannelTransactionParameters(DirectedChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(DirectedChannelTransactionParameters)); } - DirectedChannelTransactionParameters(LDKDirectedChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectedChannelTransactionParameters)); } - operator LDKDirectedChannelTransactionParameters() && { LDKDirectedChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKDirectedChannelTransactionParameters)); return res; } - ~DirectedChannelTransactionParameters() { DirectedChannelTransactionParameters_free(self); } - DirectedChannelTransactionParameters& operator=(DirectedChannelTransactionParameters&& o) { DirectedChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(DirectedChannelTransactionParameters)); return *this; } - LDKDirectedChannelTransactionParameters* operator &() { return &self; } - LDKDirectedChannelTransactionParameters* operator ->() { return &self; } - const LDKDirectedChannelTransactionParameters* operator &() const { return &self; } - const LDKDirectedChannelTransactionParameters* operator ->() const { return &self; } -}; -class HolderCommitmentTransaction { -private: - LDKHolderCommitmentTransaction self; -public: - HolderCommitmentTransaction(const HolderCommitmentTransaction&) = delete; - HolderCommitmentTransaction(HolderCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(HolderCommitmentTransaction)); } - HolderCommitmentTransaction(LDKHolderCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHolderCommitmentTransaction)); } - operator LDKHolderCommitmentTransaction() && { LDKHolderCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKHolderCommitmentTransaction)); return res; } - ~HolderCommitmentTransaction() { HolderCommitmentTransaction_free(self); } - HolderCommitmentTransaction& operator=(HolderCommitmentTransaction&& o) { HolderCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(HolderCommitmentTransaction)); return *this; } - LDKHolderCommitmentTransaction* operator &() { return &self; } - LDKHolderCommitmentTransaction* operator ->() { return &self; } - const LDKHolderCommitmentTransaction* operator &() const { return &self; } - const LDKHolderCommitmentTransaction* operator ->() const { return &self; } -}; -class BuiltCommitmentTransaction { -private: - LDKBuiltCommitmentTransaction self; -public: - BuiltCommitmentTransaction(const BuiltCommitmentTransaction&) = delete; - BuiltCommitmentTransaction(BuiltCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(BuiltCommitmentTransaction)); } - BuiltCommitmentTransaction(LDKBuiltCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBuiltCommitmentTransaction)); } - operator LDKBuiltCommitmentTransaction() && { LDKBuiltCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKBuiltCommitmentTransaction)); return res; } - ~BuiltCommitmentTransaction() { BuiltCommitmentTransaction_free(self); } - BuiltCommitmentTransaction& operator=(BuiltCommitmentTransaction&& o) { BuiltCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(BuiltCommitmentTransaction)); return *this; } - LDKBuiltCommitmentTransaction* operator &() { return &self; } - LDKBuiltCommitmentTransaction* operator ->() { return &self; } - const LDKBuiltCommitmentTransaction* operator &() const { return &self; } - const LDKBuiltCommitmentTransaction* operator ->() const { return &self; } -}; -class ClosingTransaction { -private: - LDKClosingTransaction self; -public: - ClosingTransaction(const ClosingTransaction&) = delete; - ClosingTransaction(ClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingTransaction)); } - ClosingTransaction(LDKClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingTransaction)); } - operator LDKClosingTransaction() && { LDKClosingTransaction res = self; memset(&self, 0, sizeof(LDKClosingTransaction)); return res; } - ~ClosingTransaction() { ClosingTransaction_free(self); } - ClosingTransaction& operator=(ClosingTransaction&& o) { ClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(ClosingTransaction)); return *this; } - LDKClosingTransaction* operator &() { return &self; } - LDKClosingTransaction* operator ->() { return &self; } - const LDKClosingTransaction* operator &() const { return &self; } - const LDKClosingTransaction* operator ->() const { return &self; } -}; -class TrustedClosingTransaction { -private: - LDKTrustedClosingTransaction self; -public: - TrustedClosingTransaction(const TrustedClosingTransaction&) = delete; - TrustedClosingTransaction(TrustedClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedClosingTransaction)); } - TrustedClosingTransaction(LDKTrustedClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedClosingTransaction)); } - operator LDKTrustedClosingTransaction() && { LDKTrustedClosingTransaction res = self; memset(&self, 0, sizeof(LDKTrustedClosingTransaction)); return res; } - ~TrustedClosingTransaction() { TrustedClosingTransaction_free(self); } - TrustedClosingTransaction& operator=(TrustedClosingTransaction&& o) { TrustedClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(TrustedClosingTransaction)); return *this; } - LDKTrustedClosingTransaction* operator &() { return &self; } - LDKTrustedClosingTransaction* operator ->() { return &self; } - const LDKTrustedClosingTransaction* operator &() const { return &self; } - const LDKTrustedClosingTransaction* operator ->() const { return &self; } -}; -class CommitmentTransaction { -private: - LDKCommitmentTransaction self; -public: - CommitmentTransaction(const CommitmentTransaction&) = delete; - CommitmentTransaction(CommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentTransaction)); } - CommitmentTransaction(LDKCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentTransaction)); } - operator LDKCommitmentTransaction() && { LDKCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKCommitmentTransaction)); return res; } - ~CommitmentTransaction() { CommitmentTransaction_free(self); } - CommitmentTransaction& operator=(CommitmentTransaction&& o) { CommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentTransaction)); return *this; } - LDKCommitmentTransaction* operator &() { return &self; } - LDKCommitmentTransaction* operator ->() { return &self; } - const LDKCommitmentTransaction* operator &() const { return &self; } - const LDKCommitmentTransaction* operator ->() const { return &self; } -}; -class TrustedCommitmentTransaction { -private: - LDKTrustedCommitmentTransaction self; -public: - TrustedCommitmentTransaction(const TrustedCommitmentTransaction&) = delete; - TrustedCommitmentTransaction(TrustedCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedCommitmentTransaction)); } - TrustedCommitmentTransaction(LDKTrustedCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedCommitmentTransaction)); } - operator LDKTrustedCommitmentTransaction() && { LDKTrustedCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKTrustedCommitmentTransaction)); return res; } - ~TrustedCommitmentTransaction() { TrustedCommitmentTransaction_free(self); } - TrustedCommitmentTransaction& operator=(TrustedCommitmentTransaction&& o) { TrustedCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(TrustedCommitmentTransaction)); return *this; } - LDKTrustedCommitmentTransaction* operator &() { return &self; } - LDKTrustedCommitmentTransaction* operator ->() { return &self; } - const LDKTrustedCommitmentTransaction* operator &() const { return &self; } - const LDKTrustedCommitmentTransaction* operator ->() const { return &self; } -}; -class ShutdownScript { -private: - LDKShutdownScript self; -public: - ShutdownScript(const ShutdownScript&) = delete; - ShutdownScript(ShutdownScript&& o) : self(o.self) { memset(&o, 0, sizeof(ShutdownScript)); } - ShutdownScript(LDKShutdownScript&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShutdownScript)); } - operator LDKShutdownScript() && { LDKShutdownScript res = self; memset(&self, 0, sizeof(LDKShutdownScript)); return res; } - ~ShutdownScript() { ShutdownScript_free(self); } - ShutdownScript& operator=(ShutdownScript&& o) { ShutdownScript_free(self); self = o.self; memset(&o, 0, sizeof(ShutdownScript)); return *this; } - LDKShutdownScript* operator &() { return &self; } - LDKShutdownScript* operator ->() { return &self; } - const LDKShutdownScript* operator &() const { return &self; } - const LDKShutdownScript* operator ->() const { return &self; } -}; -class InvalidShutdownScript { +class UnsignedBolt12Invoice { private: - LDKInvalidShutdownScript self; + LDKUnsignedBolt12Invoice self; public: - InvalidShutdownScript(const InvalidShutdownScript&) = delete; - InvalidShutdownScript(InvalidShutdownScript&& o) : self(o.self) { memset(&o, 0, sizeof(InvalidShutdownScript)); } - InvalidShutdownScript(LDKInvalidShutdownScript&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvalidShutdownScript)); } - operator LDKInvalidShutdownScript() && { LDKInvalidShutdownScript res = self; memset(&self, 0, sizeof(LDKInvalidShutdownScript)); return res; } - ~InvalidShutdownScript() { InvalidShutdownScript_free(self); } - InvalidShutdownScript& operator=(InvalidShutdownScript&& o) { InvalidShutdownScript_free(self); self = o.self; memset(&o, 0, sizeof(InvalidShutdownScript)); return *this; } - LDKInvalidShutdownScript* operator &() { return &self; } - LDKInvalidShutdownScript* operator ->() { return &self; } - const LDKInvalidShutdownScript* operator &() const { return &self; } - const LDKInvalidShutdownScript* operator ->() const { return &self; } + UnsignedBolt12Invoice(const UnsignedBolt12Invoice&) = delete; + UnsignedBolt12Invoice(UnsignedBolt12Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedBolt12Invoice)); } + UnsignedBolt12Invoice(LDKUnsignedBolt12Invoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedBolt12Invoice)); } + operator LDKUnsignedBolt12Invoice() && { LDKUnsignedBolt12Invoice res = self; memset(&self, 0, sizeof(LDKUnsignedBolt12Invoice)); return res; } + ~UnsignedBolt12Invoice() { UnsignedBolt12Invoice_free(self); } + UnsignedBolt12Invoice& operator=(UnsignedBolt12Invoice&& o) { UnsignedBolt12Invoice_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedBolt12Invoice)); return *this; } + LDKUnsignedBolt12Invoice* operator &() { return &self; } + LDKUnsignedBolt12Invoice* operator ->() { return &self; } + const LDKUnsignedBolt12Invoice* operator &() const { return &self; } + const LDKUnsignedBolt12Invoice* operator ->() const { return &self; } }; -class UnsignedInvoice { +class Bolt12Invoice { private: - LDKUnsignedInvoice self; + LDKBolt12Invoice self; public: - UnsignedInvoice(const UnsignedInvoice&) = delete; - UnsignedInvoice(UnsignedInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedInvoice)); } - UnsignedInvoice(LDKUnsignedInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedInvoice)); } - operator LDKUnsignedInvoice() && { LDKUnsignedInvoice res = self; memset(&self, 0, sizeof(LDKUnsignedInvoice)); return res; } - ~UnsignedInvoice() { UnsignedInvoice_free(self); } - UnsignedInvoice& operator=(UnsignedInvoice&& o) { UnsignedInvoice_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedInvoice)); return *this; } - LDKUnsignedInvoice* operator &() { return &self; } - LDKUnsignedInvoice* operator ->() { return &self; } - const LDKUnsignedInvoice* operator &() const { return &self; } - const LDKUnsignedInvoice* operator ->() const { return &self; } + Bolt12Invoice(const Bolt12Invoice&) = delete; + Bolt12Invoice(Bolt12Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12Invoice)); } + Bolt12Invoice(LDKBolt12Invoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12Invoice)); } + operator LDKBolt12Invoice() && { LDKBolt12Invoice res = self; memset(&self, 0, sizeof(LDKBolt12Invoice)); return res; } + ~Bolt12Invoice() { Bolt12Invoice_free(self); } + Bolt12Invoice& operator=(Bolt12Invoice&& o) { Bolt12Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12Invoice)); return *this; } + LDKBolt12Invoice* operator &() { return &self; } + LDKBolt12Invoice* operator ->() { return &self; } + const LDKBolt12Invoice* operator &() const { return &self; } + const LDKBolt12Invoice* operator ->() const { return &self; } }; class BlindedPayInfo { private: @@ -845,1147 +705,1382 @@ public: const LDKBlindedPayInfo* operator &() const { return &self; } const LDKBlindedPayInfo* operator ->() const { return &self; } }; -class BackgroundProcessor { +class DelayedPaymentOutputDescriptor { private: - LDKBackgroundProcessor self; + LDKDelayedPaymentOutputDescriptor self; public: - BackgroundProcessor(const BackgroundProcessor&) = delete; - BackgroundProcessor(BackgroundProcessor&& o) : self(o.self) { memset(&o, 0, sizeof(BackgroundProcessor)); } - BackgroundProcessor(LDKBackgroundProcessor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBackgroundProcessor)); } - operator LDKBackgroundProcessor() && { LDKBackgroundProcessor res = self; memset(&self, 0, sizeof(LDKBackgroundProcessor)); return res; } - ~BackgroundProcessor() { BackgroundProcessor_free(self); } - BackgroundProcessor& operator=(BackgroundProcessor&& o) { BackgroundProcessor_free(self); self = o.self; memset(&o, 0, sizeof(BackgroundProcessor)); return *this; } - LDKBackgroundProcessor* operator &() { return &self; } - LDKBackgroundProcessor* operator ->() { return &self; } - const LDKBackgroundProcessor* operator &() const { return &self; } - const LDKBackgroundProcessor* operator ->() const { return &self; } + DelayedPaymentOutputDescriptor(const DelayedPaymentOutputDescriptor&) = delete; + DelayedPaymentOutputDescriptor(DelayedPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); } + DelayedPaymentOutputDescriptor(LDKDelayedPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); } + operator LDKDelayedPaymentOutputDescriptor() && { LDKDelayedPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); return res; } + ~DelayedPaymentOutputDescriptor() { DelayedPaymentOutputDescriptor_free(self); } + DelayedPaymentOutputDescriptor& operator=(DelayedPaymentOutputDescriptor&& o) { DelayedPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); return *this; } + LDKDelayedPaymentOutputDescriptor* operator &() { return &self; } + LDKDelayedPaymentOutputDescriptor* operator ->() { return &self; } + const LDKDelayedPaymentOutputDescriptor* operator &() const { return &self; } + const LDKDelayedPaymentOutputDescriptor* operator ->() const { return &self; } }; -class GossipSync { +class StaticPaymentOutputDescriptor { private: - LDKGossipSync self; + LDKStaticPaymentOutputDescriptor self; public: - GossipSync(const GossipSync&) = delete; - GossipSync(GossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(GossipSync)); } - GossipSync(LDKGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGossipSync)); } - operator LDKGossipSync() && { LDKGossipSync res = self; memset(&self, 0, sizeof(LDKGossipSync)); return res; } - ~GossipSync() { GossipSync_free(self); } - GossipSync& operator=(GossipSync&& o) { GossipSync_free(self); self = o.self; memset(&o, 0, sizeof(GossipSync)); return *this; } - LDKGossipSync* operator &() { return &self; } - LDKGossipSync* operator ->() { return &self; } - const LDKGossipSync* operator &() const { return &self; } - const LDKGossipSync* operator ->() const { return &self; } + StaticPaymentOutputDescriptor(const StaticPaymentOutputDescriptor&) = delete; + StaticPaymentOutputDescriptor(StaticPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); } + StaticPaymentOutputDescriptor(LDKStaticPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); } + operator LDKStaticPaymentOutputDescriptor() && { LDKStaticPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); return res; } + ~StaticPaymentOutputDescriptor() { StaticPaymentOutputDescriptor_free(self); } + StaticPaymentOutputDescriptor& operator=(StaticPaymentOutputDescriptor&& o) { StaticPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); return *this; } + LDKStaticPaymentOutputDescriptor* operator &() { return &self; } + LDKStaticPaymentOutputDescriptor* operator ->() { return &self; } + const LDKStaticPaymentOutputDescriptor* operator &() const { return &self; } + const LDKStaticPaymentOutputDescriptor* operator ->() const { return &self; } }; -class DefaultRouter { +class SpendableOutputDescriptor { private: - LDKDefaultRouter self; + LDKSpendableOutputDescriptor self; public: - DefaultRouter(const DefaultRouter&) = delete; - DefaultRouter(DefaultRouter&& o) : self(o.self) { memset(&o, 0, sizeof(DefaultRouter)); } - DefaultRouter(LDKDefaultRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDefaultRouter)); } - operator LDKDefaultRouter() && { LDKDefaultRouter res = self; memset(&self, 0, sizeof(LDKDefaultRouter)); return res; } - ~DefaultRouter() { DefaultRouter_free(self); } - DefaultRouter& operator=(DefaultRouter&& o) { DefaultRouter_free(self); self = o.self; memset(&o, 0, sizeof(DefaultRouter)); return *this; } - LDKDefaultRouter* operator &() { return &self; } - LDKDefaultRouter* operator ->() { return &self; } - const LDKDefaultRouter* operator &() const { return &self; } - const LDKDefaultRouter* operator ->() const { return &self; } + SpendableOutputDescriptor(const SpendableOutputDescriptor&) = delete; + SpendableOutputDescriptor(SpendableOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SpendableOutputDescriptor)); } + SpendableOutputDescriptor(LDKSpendableOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpendableOutputDescriptor)); } + operator LDKSpendableOutputDescriptor() && { LDKSpendableOutputDescriptor res = self; memset(&self, 0, sizeof(LDKSpendableOutputDescriptor)); return res; } + ~SpendableOutputDescriptor() { SpendableOutputDescriptor_free(self); } + SpendableOutputDescriptor& operator=(SpendableOutputDescriptor&& o) { SpendableOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SpendableOutputDescriptor)); return *this; } + LDKSpendableOutputDescriptor* operator &() { return &self; } + LDKSpendableOutputDescriptor* operator ->() { return &self; } + const LDKSpendableOutputDescriptor* operator &() const { return &self; } + const LDKSpendableOutputDescriptor* operator ->() const { return &self; } }; -class Router { +class ChannelSigner { private: - LDKRouter self; + LDKChannelSigner self; public: - Router(const Router&) = delete; - Router(Router&& o) : self(o.self) { memset(&o, 0, sizeof(Router)); } - Router(LDKRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouter)); } - operator LDKRouter() && { LDKRouter res = self; memset(&self, 0, sizeof(LDKRouter)); return res; } - ~Router() { Router_free(self); } - Router& operator=(Router&& o) { Router_free(self); self = o.self; memset(&o, 0, sizeof(Router)); return *this; } - LDKRouter* operator &() { return &self; } - LDKRouter* operator ->() { return &self; } - const LDKRouter* operator &() const { return &self; } - const LDKRouter* operator ->() const { return &self; } + ChannelSigner(const ChannelSigner&) = delete; + ChannelSigner(ChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelSigner)); } + ChannelSigner(LDKChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelSigner)); } + operator LDKChannelSigner() && { LDKChannelSigner res = self; memset(&self, 0, sizeof(LDKChannelSigner)); return res; } + ~ChannelSigner() { ChannelSigner_free(self); } + ChannelSigner& operator=(ChannelSigner&& o) { ChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(ChannelSigner)); return *this; } + LDKChannelSigner* operator &() { return &self; } + LDKChannelSigner* operator ->() { return &self; } + const LDKChannelSigner* operator &() const { return &self; } + const LDKChannelSigner* operator ->() const { return &self; } /** - * Finds a [`Route`] between `payer` and `payee` for a payment with the given values. + * Gets the per-commitment point for a specific commitment number * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. */ - inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); + inline LDKPublicKey get_per_commitment_point(uint64_t idx); /** - * Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes - * `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment. + * Gets the commitment secret for a specific commitment number as part of the revocation process * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * An external signer implementation should error here if the commitment was already signed + * and should refuse to sign it in the future. + * + * May be called more than once for the same index. + * + * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. */ - inline LDK::CResult_RouteLightningErrorZ find_route_with_id(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); -}; -class ScorerAccountingForInFlightHtlcs { -private: - LDKScorerAccountingForInFlightHtlcs self; -public: - ScorerAccountingForInFlightHtlcs(const ScorerAccountingForInFlightHtlcs&) = delete; - ScorerAccountingForInFlightHtlcs(ScorerAccountingForInFlightHtlcs&& o) : self(o.self) { memset(&o, 0, sizeof(ScorerAccountingForInFlightHtlcs)); } - ScorerAccountingForInFlightHtlcs(LDKScorerAccountingForInFlightHtlcs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKScorerAccountingForInFlightHtlcs)); } - operator LDKScorerAccountingForInFlightHtlcs() && { LDKScorerAccountingForInFlightHtlcs res = self; memset(&self, 0, sizeof(LDKScorerAccountingForInFlightHtlcs)); return res; } - ~ScorerAccountingForInFlightHtlcs() { ScorerAccountingForInFlightHtlcs_free(self); } - ScorerAccountingForInFlightHtlcs& operator=(ScorerAccountingForInFlightHtlcs&& o) { ScorerAccountingForInFlightHtlcs_free(self); self = o.self; memset(&o, 0, sizeof(ScorerAccountingForInFlightHtlcs)); return *this; } - LDKScorerAccountingForInFlightHtlcs* operator &() { return &self; } - LDKScorerAccountingForInFlightHtlcs* operator ->() { return &self; } - const LDKScorerAccountingForInFlightHtlcs* operator &() const { return &self; } - const LDKScorerAccountingForInFlightHtlcs* operator ->() const { return &self; } -}; -class InFlightHtlcs { -private: - LDKInFlightHtlcs self; -public: - InFlightHtlcs(const InFlightHtlcs&) = delete; - InFlightHtlcs(InFlightHtlcs&& o) : self(o.self) { memset(&o, 0, sizeof(InFlightHtlcs)); } - InFlightHtlcs(LDKInFlightHtlcs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInFlightHtlcs)); } - operator LDKInFlightHtlcs() && { LDKInFlightHtlcs res = self; memset(&self, 0, sizeof(LDKInFlightHtlcs)); return res; } - ~InFlightHtlcs() { InFlightHtlcs_free(self); } - InFlightHtlcs& operator=(InFlightHtlcs&& o) { InFlightHtlcs_free(self); self = o.self; memset(&o, 0, sizeof(InFlightHtlcs)); return *this; } - LDKInFlightHtlcs* operator &() { return &self; } - LDKInFlightHtlcs* operator ->() { return &self; } - const LDKInFlightHtlcs* operator &() const { return &self; } - const LDKInFlightHtlcs* operator ->() const { return &self; } -}; -class RouteHop { -private: - LDKRouteHop self; -public: - RouteHop(const RouteHop&) = delete; - RouteHop(RouteHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHop)); } - RouteHop(LDKRouteHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHop)); } - operator LDKRouteHop() && { LDKRouteHop res = self; memset(&self, 0, sizeof(LDKRouteHop)); return res; } - ~RouteHop() { RouteHop_free(self); } - RouteHop& operator=(RouteHop&& o) { RouteHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHop)); return *this; } - LDKRouteHop* operator &() { return &self; } - LDKRouteHop* operator ->() { return &self; } - const LDKRouteHop* operator &() const { return &self; } - const LDKRouteHop* operator ->() const { return &self; } -}; -class BlindedTail { -private: - LDKBlindedTail self; -public: - BlindedTail(const BlindedTail&) = delete; - BlindedTail(BlindedTail&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedTail)); } - BlindedTail(LDKBlindedTail&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedTail)); } - operator LDKBlindedTail() && { LDKBlindedTail res = self; memset(&self, 0, sizeof(LDKBlindedTail)); return res; } - ~BlindedTail() { BlindedTail_free(self); } - BlindedTail& operator=(BlindedTail&& o) { BlindedTail_free(self); self = o.self; memset(&o, 0, sizeof(BlindedTail)); return *this; } - LDKBlindedTail* operator &() { return &self; } - LDKBlindedTail* operator ->() { return &self; } - const LDKBlindedTail* operator &() const { return &self; } - const LDKBlindedTail* operator ->() const { return &self; } -}; -class Path { -private: - LDKPath self; -public: - Path(const Path&) = delete; - Path(Path&& o) : self(o.self) { memset(&o, 0, sizeof(Path)); } - Path(LDKPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPath)); } - operator LDKPath() && { LDKPath res = self; memset(&self, 0, sizeof(LDKPath)); return res; } - ~Path() { Path_free(self); } - Path& operator=(Path&& o) { Path_free(self); self = o.self; memset(&o, 0, sizeof(Path)); return *this; } - LDKPath* operator &() { return &self; } - LDKPath* operator ->() { return &self; } - const LDKPath* operator &() const { return &self; } - const LDKPath* operator ->() const { return &self; } -}; -class Route { -private: - LDKRoute self; -public: - Route(const Route&) = delete; - Route(Route&& o) : self(o.self) { memset(&o, 0, sizeof(Route)); } - Route(LDKRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoute)); } - operator LDKRoute() && { LDKRoute res = self; memset(&self, 0, sizeof(LDKRoute)); return res; } - ~Route() { Route_free(self); } - Route& operator=(Route&& o) { Route_free(self); self = o.self; memset(&o, 0, sizeof(Route)); return *this; } - LDKRoute* operator &() { return &self; } - LDKRoute* operator ->() { return &self; } - const LDKRoute* operator &() const { return &self; } - const LDKRoute* operator ->() const { return &self; } -}; -class RouteParameters { -private: - LDKRouteParameters self; -public: - RouteParameters(const RouteParameters&) = delete; - RouteParameters(RouteParameters&& o) : self(o.self) { memset(&o, 0, sizeof(RouteParameters)); } - RouteParameters(LDKRouteParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteParameters)); } - operator LDKRouteParameters() && { LDKRouteParameters res = self; memset(&self, 0, sizeof(LDKRouteParameters)); return res; } - ~RouteParameters() { RouteParameters_free(self); } - RouteParameters& operator=(RouteParameters&& o) { RouteParameters_free(self); self = o.self; memset(&o, 0, sizeof(RouteParameters)); return *this; } - LDKRouteParameters* operator &() { return &self; } - LDKRouteParameters* operator ->() { return &self; } - const LDKRouteParameters* operator &() const { return &self; } - const LDKRouteParameters* operator ->() const { return &self; } -}; -class PaymentParameters { -private: - LDKPaymentParameters self; -public: - PaymentParameters(const PaymentParameters&) = delete; - PaymentParameters(PaymentParameters&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentParameters)); } - PaymentParameters(LDKPaymentParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentParameters)); } - operator LDKPaymentParameters() && { LDKPaymentParameters res = self; memset(&self, 0, sizeof(LDKPaymentParameters)); return res; } - ~PaymentParameters() { PaymentParameters_free(self); } - PaymentParameters& operator=(PaymentParameters&& o) { PaymentParameters_free(self); self = o.self; memset(&o, 0, sizeof(PaymentParameters)); return *this; } - LDKPaymentParameters* operator &() { return &self; } - LDKPaymentParameters* operator ->() { return &self; } - const LDKPaymentParameters* operator &() const { return &self; } - const LDKPaymentParameters* operator ->() const { return &self; } + inline LDKThirtyTwoBytes release_commitment_secret(uint64_t idx); + /** + * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + * + * This is required in order for the signer to make sure that releasing a commitment + * secret won't leave us without a broadcastable holder transaction. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * Note that all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. + */ + inline LDK::CResult_NoneNoneZ validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); + /** + * Returns an arbitrary identifier describing the set of keys which are provided back to you in + * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this + * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. + */ + inline LDKThirtyTwoBytes channel_keys_id(); + /** + * Set the counterparty static channel data, including basepoints, + * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. + * + * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] + * instance, LDK will call this method exactly once - either immediately after construction + * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding + * information has been generated. + * + * channel_parameters.is_populated() MUST be true. + */ + inline void provide_channel_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); }; -class Hints { +class EcdsaChannelSigner { private: - LDKHints self; + LDKEcdsaChannelSigner self; public: - Hints(const Hints&) = delete; - Hints(Hints&& o) : self(o.self) { memset(&o, 0, sizeof(Hints)); } - Hints(LDKHints&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHints)); } - operator LDKHints() && { LDKHints res = self; memset(&self, 0, sizeof(LDKHints)); return res; } - ~Hints() { Hints_free(self); } - Hints& operator=(Hints&& o) { Hints_free(self); self = o.self; memset(&o, 0, sizeof(Hints)); return *this; } - LDKHints* operator &() { return &self; } - LDKHints* operator ->() { return &self; } - const LDKHints* operator &() const { return &self; } - const LDKHints* operator ->() const { return &self; } -}; -class RouteHint { -private: - LDKRouteHint self; -public: - RouteHint(const RouteHint&) = delete; - RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); } - RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); } - operator LDKRouteHint() && { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; } - ~RouteHint() { RouteHint_free(self); } - RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } - LDKRouteHint* operator &() { return &self; } - LDKRouteHint* operator ->() { return &self; } - const LDKRouteHint* operator &() const { return &self; } - const LDKRouteHint* operator ->() const { return &self; } -}; -class RouteHintHop { -private: - LDKRouteHintHop self; -public: - RouteHintHop(const RouteHintHop&) = delete; - RouteHintHop(RouteHintHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHintHop)); } - RouteHintHop(LDKRouteHintHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHintHop)); } - operator LDKRouteHintHop() && { LDKRouteHintHop res = self; memset(&self, 0, sizeof(LDKRouteHintHop)); return res; } - ~RouteHintHop() { RouteHintHop_free(self); } - RouteHintHop& operator=(RouteHintHop&& o) { RouteHintHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHintHop)); return *this; } - LDKRouteHintHop* operator &() { return &self; } - LDKRouteHintHop* operator ->() { return &self; } - const LDKRouteHintHop* operator &() const { return &self; } - const LDKRouteHintHop* operator ->() const { return &self; } -}; -class BroadcasterInterface { -private: - LDKBroadcasterInterface self; -public: - BroadcasterInterface(const BroadcasterInterface&) = delete; - BroadcasterInterface(BroadcasterInterface&& o) : self(o.self) { memset(&o, 0, sizeof(BroadcasterInterface)); } - BroadcasterInterface(LDKBroadcasterInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBroadcasterInterface)); } - operator LDKBroadcasterInterface() && { LDKBroadcasterInterface res = self; memset(&self, 0, sizeof(LDKBroadcasterInterface)); return res; } - ~BroadcasterInterface() { BroadcasterInterface_free(self); } - BroadcasterInterface& operator=(BroadcasterInterface&& o) { BroadcasterInterface_free(self); self = o.self; memset(&o, 0, sizeof(BroadcasterInterface)); return *this; } - LDKBroadcasterInterface* operator &() { return &self; } - LDKBroadcasterInterface* operator ->() { return &self; } - const LDKBroadcasterInterface* operator &() const { return &self; } - const LDKBroadcasterInterface* operator ->() const { return &self; } - /** - * Sends a transaction out to (hopefully) be mined. - */ - inline void broadcast_transaction(struct LDKTransaction tx); -}; -class ConfirmationTarget { -private: - LDKConfirmationTarget self; -public: - ConfirmationTarget(const ConfirmationTarget&) = delete; - ConfirmationTarget(ConfirmationTarget&& o) : self(o.self) { memset(&o, 0, sizeof(ConfirmationTarget)); } - ConfirmationTarget(LDKConfirmationTarget&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirmationTarget)); } - operator LDKConfirmationTarget() && { LDKConfirmationTarget res = self; memset(&self, 0, sizeof(LDKConfirmationTarget)); return res; } - ConfirmationTarget& operator=(ConfirmationTarget&& o) { self = o.self; memset(&o, 0, sizeof(ConfirmationTarget)); return *this; } - LDKConfirmationTarget* operator &() { return &self; } - LDKConfirmationTarget* operator ->() { return &self; } - const LDKConfirmationTarget* operator &() const { return &self; } - const LDKConfirmationTarget* operator ->() const { return &self; } -}; -class FeeEstimator { -private: - LDKFeeEstimator self; -public: - FeeEstimator(const FeeEstimator&) = delete; - FeeEstimator(FeeEstimator&& o) : self(o.self) { memset(&o, 0, sizeof(FeeEstimator)); } - FeeEstimator(LDKFeeEstimator&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFeeEstimator)); } - operator LDKFeeEstimator() && { LDKFeeEstimator res = self; memset(&self, 0, sizeof(LDKFeeEstimator)); return res; } - ~FeeEstimator() { FeeEstimator_free(self); } - FeeEstimator& operator=(FeeEstimator&& o) { FeeEstimator_free(self); self = o.self; memset(&o, 0, sizeof(FeeEstimator)); return *this; } - LDKFeeEstimator* operator &() { return &self; } - LDKFeeEstimator* operator ->() { return &self; } - const LDKFeeEstimator* operator &() const { return &self; } - const LDKFeeEstimator* operator ->() const { return &self; } + EcdsaChannelSigner(const EcdsaChannelSigner&) = delete; + EcdsaChannelSigner(EcdsaChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(EcdsaChannelSigner)); } + EcdsaChannelSigner(LDKEcdsaChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEcdsaChannelSigner)); } + operator LDKEcdsaChannelSigner() && { LDKEcdsaChannelSigner res = self; memset(&self, 0, sizeof(LDKEcdsaChannelSigner)); return res; } + ~EcdsaChannelSigner() { EcdsaChannelSigner_free(self); } + EcdsaChannelSigner& operator=(EcdsaChannelSigner&& o) { EcdsaChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(EcdsaChannelSigner)); return *this; } + LDKEcdsaChannelSigner* operator &() { return &self; } + LDKEcdsaChannelSigner* operator ->() { return &self; } + const LDKEcdsaChannelSigner* operator &() const { return &self; } + const LDKEcdsaChannelSigner* operator ->() const { return &self; } /** - * Gets estimated satoshis of fee required per 1000 Weight-Units. + * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. * - * LDK will wrap this method and ensure that the value returned is no smaller than 253 - * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte). + * Note that if signing fails or is rejected, the channel will be force-closed. * - * The following unit conversions can be used to convert to sats/KW: - * * satoshis-per-byte * 250 - * * satoshis-per-kbyte / 4 - */ - inline uint32_t get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target); -}; -class BestBlock { -private: - LDKBestBlock self; -public: - BestBlock(const BestBlock&) = delete; - BestBlock(BestBlock&& o) : self(o.self) { memset(&o, 0, sizeof(BestBlock)); } - BestBlock(LDKBestBlock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBestBlock)); } - operator LDKBestBlock() && { LDKBestBlock res = self; memset(&self, 0, sizeof(LDKBestBlock)); return res; } - ~BestBlock() { BestBlock_free(self); } - BestBlock& operator=(BestBlock&& o) { BestBlock_free(self); self = o.self; memset(&o, 0, sizeof(BestBlock)); return *this; } - LDKBestBlock* operator &() { return &self; } - LDKBestBlock* operator ->() { return &self; } - const LDKBestBlock* operator &() const { return &self; } - const LDKBestBlock* operator ->() const { return &self; } -}; -class Listen { -private: - LDKListen self; -public: - Listen(const Listen&) = delete; - Listen(Listen&& o) : self(o.self) { memset(&o, 0, sizeof(Listen)); } - Listen(LDKListen&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKListen)); } - operator LDKListen() && { LDKListen res = self; memset(&self, 0, sizeof(LDKListen)); return res; } - ~Listen() { Listen_free(self); } - Listen& operator=(Listen&& o) { Listen_free(self); self = o.self; memset(&o, 0, sizeof(Listen)); return *this; } - LDKListen* operator &() { return &self; } - LDKListen* operator ->() { return &self; } - const LDKListen* operator &() const { return &self; } - const LDKListen* operator ->() const { return &self; } - /** - * Notifies the listener that a block was added at the given height, with the transaction data - * possibly filtered. + * Policy checks should be implemented in this function, including checking the amount + * sent to us and checking the HTLCs. + * + * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + * A validating signer should ensure that an HTLC output is removed only when the matching + * preimage is provided, or when the value to holder is restored. + * + * Note that all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - inline void filtered_block_connected(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); /** - * Notifies the listener that a block was added at the given height. + * Validate the counterparty's revocation. + * + * This is required in order for the signer to make sure that the state has moved + * forward and it is safe to sign the next counterparty commitment. */ - inline void block_connected(struct LDKu8slice block, uint32_t height); + inline LDK::CResult_NoneNoneZ validate_counterparty_revocation(uint64_t idx, const uint8_t (*secret)[32]); /** - * Notifies the listener that a block was removed at the given height. + * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. + * + * This will be called + * - with a non-revoked `commitment_tx`. + * - with the latest `commitment_tx` when we initiate a force-close. + * - with the previous `commitment_tx`, just to get claiming HTLC + * signatures, if we are reacting to a [`ChannelMonitor`] + * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) + * that decided to broadcast before it had been updated to the latest `commitment_tx`. + * + * This may be called multiple times for the same transaction. + * + * An external signer implementation should check that the commitment has not been revoked. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ - inline void block_disconnected(const uint8_t (*header)[80], uint32_t height); -}; -class Confirm { -private: - LDKConfirm self; -public: - Confirm(const Confirm&) = delete; - Confirm(Confirm&& o) : self(o.self) { memset(&o, 0, sizeof(Confirm)); } - Confirm(LDKConfirm&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirm)); } - operator LDKConfirm() && { LDKConfirm res = self; memset(&self, 0, sizeof(LDKConfirm)); return res; } - ~Confirm() { Confirm_free(self); } - Confirm& operator=(Confirm&& o) { Confirm_free(self); self = o.self; memset(&o, 0, sizeof(Confirm)); return *this; } - LDKConfirm* operator &() { return &self; } - LDKConfirm* operator ->() { return &self; } - const LDKConfirm* operator &() const { return &self; } - const LDKConfirm* operator ->() const { return &self; } + inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** - * Notifies LDK of transactions confirmed in a block with a given header and height. + * Create a signature for the given input in a transaction spending an HTLC transaction output + * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. * - * Must be called for any transactions registered by [`Filter::register_tx`] or any - * transactions spending an output registered by [`Filter::register_output`]. Such transactions - * appearing in the same block do not need to be included in the same call; instead, multiple - * calls with additional transactions may be made so long as they are made in [chain order]. + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. * - * May be called before or after [`best_block_updated`] for the corresponding block. However, - * in the event of a chain reorganization, it must not be called with a `header` that is no - * longer in the chain as of the last call to [`best_block_updated`]. + * Amount is value of the output spent by this input, committed to in the BIP 143 signature. * - * [chain order]: Confirm#order - * [`best_block_updated`]: Self::best_block_updated + * `per_commitment_key` is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do + * so). */ - inline void transactions_confirmed(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + inline LDK::CResult_SignatureNoneZ sign_justice_revoked_output(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); /** - * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. + * Create a signature for the given input in a transaction spending a commitment transaction + * HTLC output when our counterparty broadcasts an old state. * - * Must be called for any transaction returned by [`get_relevant_txids`] if it has been - * reorganized out of the best chain or if it is no longer confirmed in the block with the - * given block hash. Once called, the given transaction will not be returned - * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. + * A justice transaction may claim multiple outputs at the same time if timelocks are + * similar, but only a signature for the input at index `input` should be signed for here. + * It may be called multiple times for same output(s) if a fee-bump is needed with regards + * to an upcoming timelock expiration. * - * [`get_relevant_txids`]: Self::get_relevant_txids - * [`transactions_confirmed`]: Self::transactions_confirmed + * `amount` is the value of the output spent by this input, committed to in the BIP 143 + * signature. + * + * `per_commitment_key` is revocation secret which was provided by our counterparty when they + * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + * not allow the spending of any funds by itself (you need our holder revocation_secret to do + * so). + * + * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script + * (which is committed to in the BIP 143 signatures). */ - inline void transaction_unconfirmed(const uint8_t (*txid)[32]); + inline LDK::CResult_SignatureNoneZ sign_justice_revoked_htlc(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** - * Notifies LDK of an update to the best header connected at the given height. + * Computes the signature for a commitment transaction's HTLC output used as an input within + * `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned + * must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to + * sign HTLC transactions from channels supporting anchor outputs after all additional + * inputs/outputs have been added to the transaction. * - * Must be called whenever a new chain tip becomes available. May be skipped for intermediary - * blocks. + * [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All */ - inline void best_block_updated(const uint8_t (*header)[80], uint32_t height); + inline LDK::CResult_SignatureNoneZ sign_holder_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, const struct LDKHTLCDescriptor *NONNULL_PTR htlc_descriptor); /** - * Returns transactions that must be monitored for reorganization out of the chain along - * with the hash of the block as part of which it had been previously confirmed. - * - * Note that the returned `Option` might be `None` for channels created with LDK - * 0.0.112 and prior, in which case you need to manually track previous confirmations. + * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment + * transaction, either offered or received. * - * Will include any transactions passed to [`transactions_confirmed`] that have insufficient - * confirmations to be safe from a chain reorganization. Will not include any transactions - * passed to [`transaction_unconfirmed`], unless later reconfirmed. + * Such a transaction may claim multiples offered outputs at same time if we know the + * preimage for each when we create it, but only the input at index `input` should be + * signed for here. It may be called multiple times for same output(s) if a fee-bump is + * needed with regards to an upcoming timelock expiration. * - * Must be called to determine the subset of transactions that must be monitored for - * reorganization. Will be idempotent between calls but may change as a result of calls to the - * other interface methods. Thus, this is useful to determine which transactions must be - * given to [`transaction_unconfirmed`]. + * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC + * outputs. * - * If any of the returned transactions are confirmed in a block other than the one with the - * given hash, they need to be unconfirmed and reconfirmed via [`transaction_unconfirmed`] and - * [`transactions_confirmed`], respectively. + * `amount` is value of the output spent by this input, committed to in the BIP 143 signature. * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - */ - inline LDK::CVec_C2Tuple_TxidBlockHashZZ get_relevant_txids(); + * `per_commitment_point` is the dynamic point corresponding to the channel state + * detected onchain. It has been generated by our counterparty and is used to derive + * channel state keys, which are then included in the witness script and committed to in the + * BIP 143 signature. + */ + inline LDK::CResult_SignatureNoneZ sign_counterparty_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + /** + * Create a signature for a (proposed) closing transaction. + * + * Note that, due to rounding, there may be one "missing" satoshi, and either party may have + * chosen to forgo their output as dust. + */ + inline LDK::CResult_SignatureNoneZ sign_closing_transaction(const struct LDKClosingTransaction *NONNULL_PTR closing_tx); + /** + * Computes the signature for a commitment transaction's anchor output used as an + * input within `anchor_tx`, which spends the commitment transaction, at index `input`. + */ + inline LDK::CResult_SignatureNoneZ sign_holder_anchor_input(struct LDKTransaction anchor_tx, uintptr_t input); + /** + * Signs a channel announcement message with our funding key proving it comes from one of the + * channel participants. + * + * Channel announcements also require a signature from each node's network key. Our node + * signature is computed through [`NodeSigner::sign_gossip_message`]. + * + * Note that if this fails or is rejected, the channel will not be publicly announced and + * our counterparty may (though likely will not) close the channel on us for violating the + * protocol. + */ + inline LDK::CResult_SignatureNoneZ sign_channel_announcement_with_funding_key(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); }; -class ChannelMonitorUpdateStatus { +class WriteableEcdsaChannelSigner { private: - LDKChannelMonitorUpdateStatus self; + LDKWriteableEcdsaChannelSigner self; public: - ChannelMonitorUpdateStatus(const ChannelMonitorUpdateStatus&) = delete; - ChannelMonitorUpdateStatus(ChannelMonitorUpdateStatus&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdateStatus)); } - ChannelMonitorUpdateStatus(LDKChannelMonitorUpdateStatus&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdateStatus)); } - operator LDKChannelMonitorUpdateStatus() && { LDKChannelMonitorUpdateStatus res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdateStatus)); return res; } - ChannelMonitorUpdateStatus& operator=(ChannelMonitorUpdateStatus&& o) { self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdateStatus)); return *this; } - LDKChannelMonitorUpdateStatus* operator &() { return &self; } - LDKChannelMonitorUpdateStatus* operator ->() { return &self; } - const LDKChannelMonitorUpdateStatus* operator &() const { return &self; } - const LDKChannelMonitorUpdateStatus* operator ->() const { return &self; } + WriteableEcdsaChannelSigner(const WriteableEcdsaChannelSigner&) = delete; + WriteableEcdsaChannelSigner(WriteableEcdsaChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); } + WriteableEcdsaChannelSigner(LDKWriteableEcdsaChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); } + operator LDKWriteableEcdsaChannelSigner() && { LDKWriteableEcdsaChannelSigner res = self; memset(&self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); return res; } + ~WriteableEcdsaChannelSigner() { WriteableEcdsaChannelSigner_free(self); } + WriteableEcdsaChannelSigner& operator=(WriteableEcdsaChannelSigner&& o) { WriteableEcdsaChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); return *this; } + LDKWriteableEcdsaChannelSigner* operator &() { return &self; } + LDKWriteableEcdsaChannelSigner* operator ->() { return &self; } + const LDKWriteableEcdsaChannelSigner* operator &() const { return &self; } + const LDKWriteableEcdsaChannelSigner* operator ->() const { return &self; } }; -class Watch { +class Recipient { private: - LDKWatch self; + LDKRecipient self; public: - Watch(const Watch&) = delete; - Watch(Watch&& o) : self(o.self) { memset(&o, 0, sizeof(Watch)); } - Watch(LDKWatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatch)); } - operator LDKWatch() && { LDKWatch res = self; memset(&self, 0, sizeof(LDKWatch)); return res; } - ~Watch() { Watch_free(self); } - Watch& operator=(Watch&& o) { Watch_free(self); self = o.self; memset(&o, 0, sizeof(Watch)); return *this; } - LDKWatch* operator &() { return &self; } - LDKWatch* operator ->() { return &self; } - const LDKWatch* operator &() const { return &self; } - const LDKWatch* operator ->() const { return &self; } + Recipient(const Recipient&) = delete; + Recipient(Recipient&& o) : self(o.self) { memset(&o, 0, sizeof(Recipient)); } + Recipient(LDKRecipient&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecipient)); } + operator LDKRecipient() && { LDKRecipient res = self; memset(&self, 0, sizeof(LDKRecipient)); return res; } + Recipient& operator=(Recipient&& o) { self = o.self; memset(&o, 0, sizeof(Recipient)); return *this; } + LDKRecipient* operator &() { return &self; } + LDKRecipient* operator ->() { return &self; } + const LDKRecipient* operator &() const { return &self; } + const LDKRecipient* operator ->() const { return &self; } +}; +class EntropySource { +private: + LDKEntropySource self; +public: + EntropySource(const EntropySource&) = delete; + EntropySource(EntropySource&& o) : self(o.self) { memset(&o, 0, sizeof(EntropySource)); } + EntropySource(LDKEntropySource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEntropySource)); } + operator LDKEntropySource() && { LDKEntropySource res = self; memset(&self, 0, sizeof(LDKEntropySource)); return res; } + ~EntropySource() { EntropySource_free(self); } + EntropySource& operator=(EntropySource&& o) { EntropySource_free(self); self = o.self; memset(&o, 0, sizeof(EntropySource)); return *this; } + LDKEntropySource* operator &() { return &self; } + LDKEntropySource* operator ->() { return &self; } + const LDKEntropySource* operator &() const { return &self; } + const LDKEntropySource* operator ->() const { return &self; } /** - * Watches a channel identified by `funding_txo` using `monitor`. + * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a + * different value each time it is called. + */ + inline LDKThirtyTwoBytes get_secure_random_bytes(); +}; +class NodeSigner { +private: + LDKNodeSigner self; +public: + NodeSigner(const NodeSigner&) = delete; + NodeSigner(NodeSigner&& o) : self(o.self) { memset(&o, 0, sizeof(NodeSigner)); } + NodeSigner(LDKNodeSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeSigner)); } + operator LDKNodeSigner() && { LDKNodeSigner res = self; memset(&self, 0, sizeof(LDKNodeSigner)); return res; } + ~NodeSigner() { NodeSigner_free(self); } + NodeSigner& operator=(NodeSigner&& o) { NodeSigner_free(self); self = o.self; memset(&o, 0, sizeof(NodeSigner)); return *this; } + LDKNodeSigner* operator &() { return &self; } + LDKNodeSigner* operator ->() { return &self; } + const LDKNodeSigner* operator &() const { return &self; } + const LDKNodeSigner* operator ->() const { return &self; } + /** + * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. * - * Implementations are responsible for watching the chain for the funding transaction along - * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * If the implementor of this trait supports [phantom node payments], then every node that is + * intended to be included in the phantom invoice route hints must return the same value from + * this method. * - * Note: this interface MUST error with [`ChannelMonitorUpdateStatus::PermanentFailure`] if - * the given `funding_txo` has previously been registered via `watch_channel`. + * This method must return the same value each time it is called. * - * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + * [phantom node payments]: PhantomKeysManager */ - inline LDK::ChannelMonitorUpdateStatus watch_channel(struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + inline LDKThirtyTwoBytes get_inbound_payment_key_material(); /** - * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * Get node id based on the provided [`Recipient`]. * - * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. + * This method must return the same value each time it is called with a given [`Recipient`] + * parameter. * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - inline LDK::ChannelMonitorUpdateStatus update_channel(struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update); + inline LDK::CResult_PublicKeyNoneZ get_node_id(enum LDKRecipient recipient); /** - * Returns any monitor events since the last call. Subsequent calls must only return new - * events. + * Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if + * one is provided. Note that this tweak can be applied to `other_key` instead of our node + * secret, though this is less efficient. * - * 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. + * Note that if this fails while attempting to forward an HTLC, LDK will panic. The error + * should be resolved to allow LDK to resume forwarding HTLCs. * - * For details on asynchronous [`ChannelMonitor`] updating and returning - * [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events(); -}; -class Filter { -private: - LDKFilter self; -public: - Filter(const Filter&) = delete; - Filter(Filter&& o) : self(o.self) { memset(&o, 0, sizeof(Filter)); } - Filter(LDKFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilter)); } - operator LDKFilter() && { LDKFilter res = self; memset(&self, 0, sizeof(LDKFilter)); return res; } - ~Filter() { Filter_free(self); } - Filter& operator=(Filter&& o) { Filter_free(self); self = o.self; memset(&o, 0, sizeof(Filter)); return *this; } - LDKFilter* operator &() { return &self; } - LDKFilter* operator ->() { return &self; } - const LDKFilter* operator &() const { return &self; } - const LDKFilter* operator ->() const { return &self; } + inline LDK::CResult_SharedSecretNoneZ ecdh(enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak); /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. + * Sign an invoice. + * + * By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of + * this trait to parse the invoice and make sure they're signing what they expect, rather than + * blindly signing the hash. + * + * The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. + * + * The secret key used to sign the invoice is dependent on the [`Recipient`]. + * + * Errors if the [`Recipient`] variant is not supported by the implementation. */ - inline void register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); /** - * Registers interest in spends of a transaction output. + * Sign a gossip message. * - * Note that this method might be called during processing of a new block. You therefore need - * to ensure that also dependent output spents within an already connected block are correctly - * handled, e.g., by re-scanning the block in question whenever new outputs have been - * registered mid-processing. + * Note that if this fails, LDK may panic and the message will not be broadcast to the network + * or a possible channel counterparty. If LDK panics, the error should be resolved to allow the + * message to be broadcast, as otherwise it may prevent one from receiving funds over the + * corresponding channel. */ - inline void register_output(struct LDKWatchedOutput output); -}; -class WatchedOutput { -private: - LDKWatchedOutput self; -public: - WatchedOutput(const WatchedOutput&) = delete; - WatchedOutput(WatchedOutput&& o) : self(o.self) { memset(&o, 0, sizeof(WatchedOutput)); } - WatchedOutput(LDKWatchedOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatchedOutput)); } - operator LDKWatchedOutput() && { LDKWatchedOutput res = self; memset(&self, 0, sizeof(LDKWatchedOutput)); return res; } - ~WatchedOutput() { WatchedOutput_free(self); } - WatchedOutput& operator=(WatchedOutput&& o) { WatchedOutput_free(self); self = o.self; memset(&o, 0, sizeof(WatchedOutput)); return *this; } - LDKWatchedOutput* operator &() { return &self; } - LDKWatchedOutput* operator ->() { return &self; } - const LDKWatchedOutput* operator &() const { return &self; } - const LDKWatchedOutput* operator ->() const { return &self; } + inline LDK::CResult_SignatureNoneZ sign_gossip_message(struct LDKUnsignedGossipMessage msg); }; -class Score { +class SignerProvider { private: - LDKScore self; + LDKSignerProvider self; public: - Score(const Score&) = delete; - Score(Score&& o) : self(o.self) { memset(&o, 0, sizeof(Score)); } - Score(LDKScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKScore)); } - operator LDKScore() && { LDKScore res = self; memset(&self, 0, sizeof(LDKScore)); return res; } - ~Score() { Score_free(self); } - Score& operator=(Score&& o) { Score_free(self); self = o.self; memset(&o, 0, sizeof(Score)); return *this; } - LDKScore* operator &() { return &self; } - LDKScore* operator ->() { return &self; } - const LDKScore* operator &() const { return &self; } - const LDKScore* operator ->() const { return &self; } + SignerProvider(const SignerProvider&) = delete; + SignerProvider(SignerProvider&& o) : self(o.self) { memset(&o, 0, sizeof(SignerProvider)); } + SignerProvider(LDKSignerProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignerProvider)); } + operator LDKSignerProvider() && { LDKSignerProvider res = self; memset(&self, 0, sizeof(LDKSignerProvider)); return res; } + ~SignerProvider() { SignerProvider_free(self); } + SignerProvider& operator=(SignerProvider&& o) { SignerProvider_free(self); self = o.self; memset(&o, 0, sizeof(SignerProvider)); return *this; } + LDKSignerProvider* operator &() { return &self; } + LDKSignerProvider* operator ->() { return &self; } + const LDKSignerProvider* operator &() const { return &self; } + const LDKSignerProvider* operator ->() const { return &self; } /** - * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the - * given channel in the direction from `source` to `target`. + * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through + * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow + * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated + * `channel_keys_id`. * - * The channel's capacity (less any other MPP parts that are also being considered for use in - * the same payment) is given by `capacity_msat`. It may be determined from various sources - * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near - * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. - * Thus, implementations should be overflow-safe. + * This method must return a different value each time it is called. */ - inline uint64_t channel_penalty_msat(uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage); + inline LDKThirtyTwoBytes generate_channel_keys_id(bool inbound, uint64_t channel_value_satoshis, struct LDKU128 user_channel_id); /** - * Handles updating channel penalties after failing to route through a channel. + * Derives the private key material backing a `Signer`. + * + * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through + * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be + * re-derived from its `channel_keys_id`, which can be obtained through its trait method + * [`ChannelSigner::channel_keys_id`]. */ - inline void payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); + inline LDK::WriteableEcdsaChannelSigner derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** - * Handles updating channel penalties after successfully routing along a path. + * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. + * This is only called during deserialization of other objects which contain + * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. + * + * This method is slowly being phased out -- it will only be called when reading objects + * written by LDK versions prior to 0.0.113. + * + * [`Signer`]: Self::Signer + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - inline void payment_path_successful(const struct LDKPath *NONNULL_PTR path); + inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); /** - * Handles updating channel penalties after a probe over the given path failed. + * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + * + * If this function returns an error, this will result in a channel failing to open. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - inline void probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); + inline LDK::CResult_ScriptNoneZ get_destination_script(); /** - * Handles updating channel penalties after a probe over the given path succeeded. + * Get a script pubkey which we will send funds to when closing a channel. + * + * If this function returns an error, this will result in a channel failing to open or close. + * In the event of a failure when the counterparty is initiating a close, this can result in a + * channel force close. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - inline void probe_successful(const struct LDKPath *NONNULL_PTR path); + inline LDK::CResult_ShutdownScriptNoneZ get_shutdown_scriptpubkey(); }; -class LockableScore { +class InMemorySigner { private: - LDKLockableScore self; + LDKInMemorySigner self; public: - LockableScore(const LockableScore&) = delete; - LockableScore(LockableScore&& o) : self(o.self) { memset(&o, 0, sizeof(LockableScore)); } - LockableScore(LDKLockableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLockableScore)); } - operator LDKLockableScore() && { LDKLockableScore res = self; memset(&self, 0, sizeof(LDKLockableScore)); return res; } - ~LockableScore() { LockableScore_free(self); } - LockableScore& operator=(LockableScore&& o) { LockableScore_free(self); self = o.self; memset(&o, 0, sizeof(LockableScore)); return *this; } - LDKLockableScore* operator &() { return &self; } - LDKLockableScore* operator ->() { return &self; } - const LDKLockableScore* operator &() const { return &self; } - const LDKLockableScore* operator ->() const { return &self; } - /** - * Returns the locked scorer. - */ - inline LDK::Score lock(); + InMemorySigner(const InMemorySigner&) = delete; + InMemorySigner(InMemorySigner&& o) : self(o.self) { memset(&o, 0, sizeof(InMemorySigner)); } + InMemorySigner(LDKInMemorySigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemorySigner)); } + operator LDKInMemorySigner() && { LDKInMemorySigner res = self; memset(&self, 0, sizeof(LDKInMemorySigner)); return res; } + ~InMemorySigner() { InMemorySigner_free(self); } + InMemorySigner& operator=(InMemorySigner&& o) { InMemorySigner_free(self); self = o.self; memset(&o, 0, sizeof(InMemorySigner)); return *this; } + LDKInMemorySigner* operator &() { return &self; } + LDKInMemorySigner* operator ->() { return &self; } + const LDKInMemorySigner* operator &() const { return &self; } + const LDKInMemorySigner* operator ->() const { return &self; } }; -class WriteableScore { +class KeysManager { private: - LDKWriteableScore self; + LDKKeysManager self; public: - WriteableScore(const WriteableScore&) = delete; - WriteableScore(WriteableScore&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableScore)); } - WriteableScore(LDKWriteableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableScore)); } - operator LDKWriteableScore() && { LDKWriteableScore res = self; memset(&self, 0, sizeof(LDKWriteableScore)); return res; } - ~WriteableScore() { WriteableScore_free(self); } - WriteableScore& operator=(WriteableScore&& o) { WriteableScore_free(self); self = o.self; memset(&o, 0, sizeof(WriteableScore)); return *this; } - LDKWriteableScore* operator &() { return &self; } - LDKWriteableScore* operator ->() { return &self; } - const LDKWriteableScore* operator &() const { return &self; } - const LDKWriteableScore* operator ->() const { return &self; } + KeysManager(const KeysManager&) = delete; + KeysManager(KeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(KeysManager)); } + KeysManager(LDKKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKKeysManager)); } + operator LDKKeysManager() && { LDKKeysManager res = self; memset(&self, 0, sizeof(LDKKeysManager)); return res; } + ~KeysManager() { KeysManager_free(self); } + KeysManager& operator=(KeysManager&& o) { KeysManager_free(self); self = o.self; memset(&o, 0, sizeof(KeysManager)); return *this; } + LDKKeysManager* operator &() { return &self; } + LDKKeysManager* operator ->() { return &self; } + const LDKKeysManager* operator &() const { return &self; } + const LDKKeysManager* operator ->() const { return &self; } }; -class MultiThreadedLockableScore { +class PhantomKeysManager { private: - LDKMultiThreadedLockableScore self; + LDKPhantomKeysManager self; public: - MultiThreadedLockableScore(const MultiThreadedLockableScore&) = delete; - MultiThreadedLockableScore(MultiThreadedLockableScore&& o) : self(o.self) { memset(&o, 0, sizeof(MultiThreadedLockableScore)); } - MultiThreadedLockableScore(LDKMultiThreadedLockableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMultiThreadedLockableScore)); } - operator LDKMultiThreadedLockableScore() && { LDKMultiThreadedLockableScore res = self; memset(&self, 0, sizeof(LDKMultiThreadedLockableScore)); return res; } - ~MultiThreadedLockableScore() { MultiThreadedLockableScore_free(self); } - MultiThreadedLockableScore& operator=(MultiThreadedLockableScore&& o) { MultiThreadedLockableScore_free(self); self = o.self; memset(&o, 0, sizeof(MultiThreadedLockableScore)); return *this; } - LDKMultiThreadedLockableScore* operator &() { return &self; } - LDKMultiThreadedLockableScore* operator ->() { return &self; } - const LDKMultiThreadedLockableScore* operator &() const { return &self; } - const LDKMultiThreadedLockableScore* operator ->() const { return &self; } + PhantomKeysManager(const PhantomKeysManager&) = delete; + PhantomKeysManager(PhantomKeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomKeysManager)); } + PhantomKeysManager(LDKPhantomKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomKeysManager)); } + operator LDKPhantomKeysManager() && { LDKPhantomKeysManager res = self; memset(&self, 0, sizeof(LDKPhantomKeysManager)); return res; } + ~PhantomKeysManager() { PhantomKeysManager_free(self); } + PhantomKeysManager& operator=(PhantomKeysManager&& o) { PhantomKeysManager_free(self); self = o.self; memset(&o, 0, sizeof(PhantomKeysManager)); return *this; } + LDKPhantomKeysManager* operator &() { return &self; } + LDKPhantomKeysManager* operator ->() { return &self; } + const LDKPhantomKeysManager* operator &() const { return &self; } + const LDKPhantomKeysManager* operator ->() const { return &self; } }; -class MultiThreadedScoreLock { +class BackgroundProcessor { private: - LDKMultiThreadedScoreLock self; + LDKBackgroundProcessor self; public: - MultiThreadedScoreLock(const MultiThreadedScoreLock&) = delete; - MultiThreadedScoreLock(MultiThreadedScoreLock&& o) : self(o.self) { memset(&o, 0, sizeof(MultiThreadedScoreLock)); } - MultiThreadedScoreLock(LDKMultiThreadedScoreLock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMultiThreadedScoreLock)); } - operator LDKMultiThreadedScoreLock() && { LDKMultiThreadedScoreLock res = self; memset(&self, 0, sizeof(LDKMultiThreadedScoreLock)); return res; } - ~MultiThreadedScoreLock() { MultiThreadedScoreLock_free(self); } - MultiThreadedScoreLock& operator=(MultiThreadedScoreLock&& o) { MultiThreadedScoreLock_free(self); self = o.self; memset(&o, 0, sizeof(MultiThreadedScoreLock)); return *this; } - LDKMultiThreadedScoreLock* operator &() { return &self; } - LDKMultiThreadedScoreLock* operator ->() { return &self; } - const LDKMultiThreadedScoreLock* operator &() const { return &self; } - const LDKMultiThreadedScoreLock* operator ->() const { return &self; } + BackgroundProcessor(const BackgroundProcessor&) = delete; + BackgroundProcessor(BackgroundProcessor&& o) : self(o.self) { memset(&o, 0, sizeof(BackgroundProcessor)); } + BackgroundProcessor(LDKBackgroundProcessor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBackgroundProcessor)); } + operator LDKBackgroundProcessor() && { LDKBackgroundProcessor res = self; memset(&self, 0, sizeof(LDKBackgroundProcessor)); return res; } + ~BackgroundProcessor() { BackgroundProcessor_free(self); } + BackgroundProcessor& operator=(BackgroundProcessor&& o) { BackgroundProcessor_free(self); self = o.self; memset(&o, 0, sizeof(BackgroundProcessor)); return *this; } + LDKBackgroundProcessor* operator &() { return &self; } + LDKBackgroundProcessor* operator ->() { return &self; } + const LDKBackgroundProcessor* operator &() const { return &self; } + const LDKBackgroundProcessor* operator ->() const { return &self; } }; -class ChannelUsage { +class GossipSync { private: - LDKChannelUsage self; + LDKGossipSync self; public: - ChannelUsage(const ChannelUsage&) = delete; - ChannelUsage(ChannelUsage&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUsage)); } - ChannelUsage(LDKChannelUsage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUsage)); } - operator LDKChannelUsage() && { LDKChannelUsage res = self; memset(&self, 0, sizeof(LDKChannelUsage)); return res; } - ~ChannelUsage() { ChannelUsage_free(self); } - ChannelUsage& operator=(ChannelUsage&& o) { ChannelUsage_free(self); self = o.self; memset(&o, 0, sizeof(ChannelUsage)); return *this; } - LDKChannelUsage* operator &() { return &self; } - LDKChannelUsage* operator ->() { return &self; } - const LDKChannelUsage* operator &() const { return &self; } - const LDKChannelUsage* operator ->() const { return &self; } + GossipSync(const GossipSync&) = delete; + GossipSync(GossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(GossipSync)); } + GossipSync(LDKGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGossipSync)); } + operator LDKGossipSync() && { LDKGossipSync res = self; memset(&self, 0, sizeof(LDKGossipSync)); return res; } + ~GossipSync() { GossipSync_free(self); } + GossipSync& operator=(GossipSync&& o) { GossipSync_free(self); self = o.self; memset(&o, 0, sizeof(GossipSync)); return *this; } + LDKGossipSync* operator &() { return &self; } + LDKGossipSync* operator ->() { return &self; } + const LDKGossipSync* operator &() const { return &self; } + const LDKGossipSync* operator ->() const { return &self; } }; -class FixedPenaltyScorer { +class DefaultRouter { private: - LDKFixedPenaltyScorer self; + LDKDefaultRouter self; public: - FixedPenaltyScorer(const FixedPenaltyScorer&) = delete; - FixedPenaltyScorer(FixedPenaltyScorer&& o) : self(o.self) { memset(&o, 0, sizeof(FixedPenaltyScorer)); } - FixedPenaltyScorer(LDKFixedPenaltyScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFixedPenaltyScorer)); } - operator LDKFixedPenaltyScorer() && { LDKFixedPenaltyScorer res = self; memset(&self, 0, sizeof(LDKFixedPenaltyScorer)); return res; } - ~FixedPenaltyScorer() { FixedPenaltyScorer_free(self); } - FixedPenaltyScorer& operator=(FixedPenaltyScorer&& o) { FixedPenaltyScorer_free(self); self = o.self; memset(&o, 0, sizeof(FixedPenaltyScorer)); return *this; } - LDKFixedPenaltyScorer* operator &() { return &self; } - LDKFixedPenaltyScorer* operator ->() { return &self; } - const LDKFixedPenaltyScorer* operator &() const { return &self; } - const LDKFixedPenaltyScorer* operator ->() const { return &self; } + DefaultRouter(const DefaultRouter&) = delete; + DefaultRouter(DefaultRouter&& o) : self(o.self) { memset(&o, 0, sizeof(DefaultRouter)); } + DefaultRouter(LDKDefaultRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDefaultRouter)); } + operator LDKDefaultRouter() && { LDKDefaultRouter res = self; memset(&self, 0, sizeof(LDKDefaultRouter)); return res; } + ~DefaultRouter() { DefaultRouter_free(self); } + DefaultRouter& operator=(DefaultRouter&& o) { DefaultRouter_free(self); self = o.self; memset(&o, 0, sizeof(DefaultRouter)); return *this; } + LDKDefaultRouter* operator &() { return &self; } + LDKDefaultRouter* operator ->() { return &self; } + const LDKDefaultRouter* operator &() const { return &self; } + const LDKDefaultRouter* operator ->() const { return &self; } }; -class ProbabilisticScorer { +class Router { private: - LDKProbabilisticScorer self; + LDKRouter self; public: - ProbabilisticScorer(const ProbabilisticScorer&) = delete; - ProbabilisticScorer(ProbabilisticScorer&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScorer)); } - ProbabilisticScorer(LDKProbabilisticScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScorer)); } - operator LDKProbabilisticScorer() && { LDKProbabilisticScorer res = self; memset(&self, 0, sizeof(LDKProbabilisticScorer)); return res; } - ~ProbabilisticScorer() { ProbabilisticScorer_free(self); } - ProbabilisticScorer& operator=(ProbabilisticScorer&& o) { ProbabilisticScorer_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScorer)); return *this; } - LDKProbabilisticScorer* operator &() { return &self; } - LDKProbabilisticScorer* operator ->() { return &self; } - const LDKProbabilisticScorer* operator &() const { return &self; } - const LDKProbabilisticScorer* operator ->() const { return &self; } + Router(const Router&) = delete; + Router(Router&& o) : self(o.self) { memset(&o, 0, sizeof(Router)); } + Router(LDKRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouter)); } + operator LDKRouter() && { LDKRouter res = self; memset(&self, 0, sizeof(LDKRouter)); return res; } + ~Router() { Router_free(self); } + Router& operator=(Router&& o) { Router_free(self); self = o.self; memset(&o, 0, sizeof(Router)); return *this; } + LDKRouter* operator &() { return &self; } + LDKRouter* operator ->() { return &self; } + const LDKRouter* operator &() const { return &self; } + const LDKRouter* operator ->() const { return &self; } + /** + * Finds a [`Route`] for a payment between the given `payer` and a payee. + * + * The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + * and [`RouteParameters::final_value_msat`], respectively. + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs); + /** + * Finds a [`Route`] for a payment between the given `payer` and a payee. + * + * The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + * and [`RouteParameters::final_value_msat`], respectively. + * + * Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific + * payment. + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::CResult_RouteLightningErrorZ find_route_with_id(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); }; -class ProbabilisticScoringParameters { +class ScorerAccountingForInFlightHtlcs { private: - LDKProbabilisticScoringParameters self; + LDKScorerAccountingForInFlightHtlcs self; public: - ProbabilisticScoringParameters(const ProbabilisticScoringParameters&) = delete; - ProbabilisticScoringParameters(ProbabilisticScoringParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScoringParameters)); } - ProbabilisticScoringParameters(LDKProbabilisticScoringParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScoringParameters)); } - operator LDKProbabilisticScoringParameters() && { LDKProbabilisticScoringParameters res = self; memset(&self, 0, sizeof(LDKProbabilisticScoringParameters)); return res; } - ~ProbabilisticScoringParameters() { ProbabilisticScoringParameters_free(self); } - ProbabilisticScoringParameters& operator=(ProbabilisticScoringParameters&& o) { ProbabilisticScoringParameters_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScoringParameters)); return *this; } - LDKProbabilisticScoringParameters* operator &() { return &self; } - LDKProbabilisticScoringParameters* operator ->() { return &self; } - const LDKProbabilisticScoringParameters* operator &() const { return &self; } - const LDKProbabilisticScoringParameters* operator ->() const { return &self; } + ScorerAccountingForInFlightHtlcs(const ScorerAccountingForInFlightHtlcs&) = delete; + ScorerAccountingForInFlightHtlcs(ScorerAccountingForInFlightHtlcs&& o) : self(o.self) { memset(&o, 0, sizeof(ScorerAccountingForInFlightHtlcs)); } + ScorerAccountingForInFlightHtlcs(LDKScorerAccountingForInFlightHtlcs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKScorerAccountingForInFlightHtlcs)); } + operator LDKScorerAccountingForInFlightHtlcs() && { LDKScorerAccountingForInFlightHtlcs res = self; memset(&self, 0, sizeof(LDKScorerAccountingForInFlightHtlcs)); return res; } + ~ScorerAccountingForInFlightHtlcs() { ScorerAccountingForInFlightHtlcs_free(self); } + ScorerAccountingForInFlightHtlcs& operator=(ScorerAccountingForInFlightHtlcs&& o) { ScorerAccountingForInFlightHtlcs_free(self); self = o.self; memset(&o, 0, sizeof(ScorerAccountingForInFlightHtlcs)); return *this; } + LDKScorerAccountingForInFlightHtlcs* operator &() { return &self; } + LDKScorerAccountingForInFlightHtlcs* operator ->() { return &self; } + const LDKScorerAccountingForInFlightHtlcs* operator &() const { return &self; } + const LDKScorerAccountingForInFlightHtlcs* operator ->() const { return &self; } }; -class OnionMessageContents { +class InFlightHtlcs { private: - LDKOnionMessageContents self; + LDKInFlightHtlcs self; public: - OnionMessageContents(const OnionMessageContents&) = delete; - OnionMessageContents(OnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageContents)); } - OnionMessageContents(LDKOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageContents)); } - operator LDKOnionMessageContents() && { LDKOnionMessageContents res = self; memset(&self, 0, sizeof(LDKOnionMessageContents)); return res; } - ~OnionMessageContents() { OnionMessageContents_free(self); } - OnionMessageContents& operator=(OnionMessageContents&& o) { OnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageContents)); return *this; } - LDKOnionMessageContents* operator &() { return &self; } - LDKOnionMessageContents* operator ->() { return &self; } - const LDKOnionMessageContents* operator &() const { return &self; } - const LDKOnionMessageContents* operator ->() const { return &self; } + InFlightHtlcs(const InFlightHtlcs&) = delete; + InFlightHtlcs(InFlightHtlcs&& o) : self(o.self) { memset(&o, 0, sizeof(InFlightHtlcs)); } + InFlightHtlcs(LDKInFlightHtlcs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInFlightHtlcs)); } + operator LDKInFlightHtlcs() && { LDKInFlightHtlcs res = self; memset(&self, 0, sizeof(LDKInFlightHtlcs)); return res; } + ~InFlightHtlcs() { InFlightHtlcs_free(self); } + InFlightHtlcs& operator=(InFlightHtlcs&& o) { InFlightHtlcs_free(self); self = o.self; memset(&o, 0, sizeof(InFlightHtlcs)); return *this; } + LDKInFlightHtlcs* operator &() { return &self; } + LDKInFlightHtlcs* operator ->() { return &self; } + const LDKInFlightHtlcs* operator &() const { return &self; } + const LDKInFlightHtlcs* operator ->() const { return &self; } }; -class CustomOnionMessageContents { +class RouteHop { private: - LDKCustomOnionMessageContents self; + LDKRouteHop self; public: - CustomOnionMessageContents(const CustomOnionMessageContents&) = delete; - CustomOnionMessageContents(CustomOnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageContents)); } - CustomOnionMessageContents(LDKCustomOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageContents)); } - operator LDKCustomOnionMessageContents() && { LDKCustomOnionMessageContents res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageContents)); return res; } - ~CustomOnionMessageContents() { CustomOnionMessageContents_free(self); } - CustomOnionMessageContents& operator=(CustomOnionMessageContents&& o) { CustomOnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageContents)); return *this; } - LDKCustomOnionMessageContents* operator &() { return &self; } - LDKCustomOnionMessageContents* operator ->() { return &self; } - const LDKCustomOnionMessageContents* operator &() const { return &self; } - const LDKCustomOnionMessageContents* operator ->() const { return &self; } - /** - * Returns the TLV type identifying the message contents. MUST be >= 64. - */ - inline uint64_t tlv_type(); + RouteHop(const RouteHop&) = delete; + RouteHop(RouteHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHop)); } + RouteHop(LDKRouteHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHop)); } + operator LDKRouteHop() && { LDKRouteHop res = self; memset(&self, 0, sizeof(LDKRouteHop)); return res; } + ~RouteHop() { RouteHop_free(self); } + RouteHop& operator=(RouteHop&& o) { RouteHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHop)); return *this; } + LDKRouteHop* operator &() { return &self; } + LDKRouteHop* operator ->() { return &self; } + const LDKRouteHop* operator &() const { return &self; } + const LDKRouteHop* operator ->() const { return &self; } }; -class InitFeatures { +class BlindedTail { private: - LDKInitFeatures self; + LDKBlindedTail self; public: - InitFeatures(const InitFeatures&) = delete; - InitFeatures(InitFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InitFeatures)); } - InitFeatures(LDKInitFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInitFeatures)); } - operator LDKInitFeatures() && { LDKInitFeatures res = self; memset(&self, 0, sizeof(LDKInitFeatures)); return res; } - ~InitFeatures() { InitFeatures_free(self); } - InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } - LDKInitFeatures* operator &() { return &self; } - LDKInitFeatures* operator ->() { return &self; } - const LDKInitFeatures* operator &() const { return &self; } - const LDKInitFeatures* operator ->() const { return &self; } + BlindedTail(const BlindedTail&) = delete; + BlindedTail(BlindedTail&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedTail)); } + BlindedTail(LDKBlindedTail&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedTail)); } + operator LDKBlindedTail() && { LDKBlindedTail res = self; memset(&self, 0, sizeof(LDKBlindedTail)); return res; } + ~BlindedTail() { BlindedTail_free(self); } + BlindedTail& operator=(BlindedTail&& o) { BlindedTail_free(self); self = o.self; memset(&o, 0, sizeof(BlindedTail)); return *this; } + LDKBlindedTail* operator &() { return &self; } + LDKBlindedTail* operator ->() { return &self; } + const LDKBlindedTail* operator &() const { return &self; } + const LDKBlindedTail* operator ->() const { return &self; } }; -class NodeFeatures { +class Path { private: - LDKNodeFeatures self; + LDKPath self; public: - NodeFeatures(const NodeFeatures&) = delete; - NodeFeatures(NodeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(NodeFeatures)); } - NodeFeatures(LDKNodeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeFeatures)); } - operator LDKNodeFeatures() && { LDKNodeFeatures res = self; memset(&self, 0, sizeof(LDKNodeFeatures)); return res; } - ~NodeFeatures() { NodeFeatures_free(self); } - NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } - LDKNodeFeatures* operator &() { return &self; } - LDKNodeFeatures* operator ->() { return &self; } - const LDKNodeFeatures* operator &() const { return &self; } - const LDKNodeFeatures* operator ->() const { return &self; } + Path(const Path&) = delete; + Path(Path&& o) : self(o.self) { memset(&o, 0, sizeof(Path)); } + Path(LDKPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPath)); } + operator LDKPath() && { LDKPath res = self; memset(&self, 0, sizeof(LDKPath)); return res; } + ~Path() { Path_free(self); } + Path& operator=(Path&& o) { Path_free(self); self = o.self; memset(&o, 0, sizeof(Path)); return *this; } + LDKPath* operator &() { return &self; } + LDKPath* operator ->() { return &self; } + const LDKPath* operator &() const { return &self; } + const LDKPath* operator ->() const { return &self; } }; -class ChannelFeatures { +class Route { private: - LDKChannelFeatures self; + LDKRoute self; public: - ChannelFeatures(const ChannelFeatures&) = delete; - ChannelFeatures(ChannelFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelFeatures)); } - ChannelFeatures(LDKChannelFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelFeatures)); } - operator LDKChannelFeatures() && { LDKChannelFeatures res = self; memset(&self, 0, sizeof(LDKChannelFeatures)); return res; } - ~ChannelFeatures() { ChannelFeatures_free(self); } - ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } - LDKChannelFeatures* operator &() { return &self; } - LDKChannelFeatures* operator ->() { return &self; } - const LDKChannelFeatures* operator &() const { return &self; } - const LDKChannelFeatures* operator ->() const { return &self; } + Route(const Route&) = delete; + Route(Route&& o) : self(o.self) { memset(&o, 0, sizeof(Route)); } + Route(LDKRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoute)); } + operator LDKRoute() && { LDKRoute res = self; memset(&self, 0, sizeof(LDKRoute)); return res; } + ~Route() { Route_free(self); } + Route& operator=(Route&& o) { Route_free(self); self = o.self; memset(&o, 0, sizeof(Route)); return *this; } + LDKRoute* operator &() { return &self; } + LDKRoute* operator ->() { return &self; } + const LDKRoute* operator &() const { return &self; } + const LDKRoute* operator ->() const { return &self; } }; -class InvoiceFeatures { +class RouteParameters { private: - LDKInvoiceFeatures self; + LDKRouteParameters self; public: - InvoiceFeatures(const InvoiceFeatures&) = delete; - InvoiceFeatures(InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceFeatures)); } - InvoiceFeatures(LDKInvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceFeatures)); } - operator LDKInvoiceFeatures() && { LDKInvoiceFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceFeatures)); return res; } - ~InvoiceFeatures() { InvoiceFeatures_free(self); } - InvoiceFeatures& operator=(InvoiceFeatures&& o) { InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceFeatures)); return *this; } - LDKInvoiceFeatures* operator &() { return &self; } - LDKInvoiceFeatures* operator ->() { return &self; } - const LDKInvoiceFeatures* operator &() const { return &self; } - const LDKInvoiceFeatures* operator ->() const { return &self; } + RouteParameters(const RouteParameters&) = delete; + RouteParameters(RouteParameters&& o) : self(o.self) { memset(&o, 0, sizeof(RouteParameters)); } + RouteParameters(LDKRouteParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteParameters)); } + operator LDKRouteParameters() && { LDKRouteParameters res = self; memset(&self, 0, sizeof(LDKRouteParameters)); return res; } + ~RouteParameters() { RouteParameters_free(self); } + RouteParameters& operator=(RouteParameters&& o) { RouteParameters_free(self); self = o.self; memset(&o, 0, sizeof(RouteParameters)); return *this; } + LDKRouteParameters* operator &() { return &self; } + LDKRouteParameters* operator ->() { return &self; } + const LDKRouteParameters* operator &() const { return &self; } + const LDKRouteParameters* operator ->() const { return &self; } }; -class OfferFeatures { +class PaymentParameters { private: - LDKOfferFeatures self; + LDKPaymentParameters self; public: - OfferFeatures(const OfferFeatures&) = delete; - OfferFeatures(OfferFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(OfferFeatures)); } - OfferFeatures(LDKOfferFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferFeatures)); } - operator LDKOfferFeatures() && { LDKOfferFeatures res = self; memset(&self, 0, sizeof(LDKOfferFeatures)); return res; } - ~OfferFeatures() { OfferFeatures_free(self); } - OfferFeatures& operator=(OfferFeatures&& o) { OfferFeatures_free(self); self = o.self; memset(&o, 0, sizeof(OfferFeatures)); return *this; } - LDKOfferFeatures* operator &() { return &self; } - LDKOfferFeatures* operator ->() { return &self; } - const LDKOfferFeatures* operator &() const { return &self; } - const LDKOfferFeatures* operator ->() const { return &self; } + PaymentParameters(const PaymentParameters&) = delete; + PaymentParameters(PaymentParameters&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentParameters)); } + PaymentParameters(LDKPaymentParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentParameters)); } + operator LDKPaymentParameters() && { LDKPaymentParameters res = self; memset(&self, 0, sizeof(LDKPaymentParameters)); return res; } + ~PaymentParameters() { PaymentParameters_free(self); } + PaymentParameters& operator=(PaymentParameters&& o) { PaymentParameters_free(self); self = o.self; memset(&o, 0, sizeof(PaymentParameters)); return *this; } + LDKPaymentParameters* operator &() { return &self; } + LDKPaymentParameters* operator ->() { return &self; } + const LDKPaymentParameters* operator &() const { return &self; } + const LDKPaymentParameters* operator ->() const { return &self; } }; -class InvoiceRequestFeatures { +class Payee { private: - LDKInvoiceRequestFeatures self; + LDKPayee self; public: - InvoiceRequestFeatures(const InvoiceRequestFeatures&) = delete; - InvoiceRequestFeatures(InvoiceRequestFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestFeatures)); } - InvoiceRequestFeatures(LDKInvoiceRequestFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestFeatures)); } - operator LDKInvoiceRequestFeatures() && { LDKInvoiceRequestFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceRequestFeatures)); return res; } - ~InvoiceRequestFeatures() { InvoiceRequestFeatures_free(self); } - InvoiceRequestFeatures& operator=(InvoiceRequestFeatures&& o) { InvoiceRequestFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestFeatures)); return *this; } - LDKInvoiceRequestFeatures* operator &() { return &self; } - LDKInvoiceRequestFeatures* operator ->() { return &self; } - const LDKInvoiceRequestFeatures* operator &() const { return &self; } - const LDKInvoiceRequestFeatures* operator ->() const { return &self; } + Payee(const Payee&) = delete; + Payee(Payee&& o) : self(o.self) { memset(&o, 0, sizeof(Payee)); } + Payee(LDKPayee&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayee)); } + operator LDKPayee() && { LDKPayee res = self; memset(&self, 0, sizeof(LDKPayee)); return res; } + ~Payee() { Payee_free(self); } + Payee& operator=(Payee&& o) { Payee_free(self); self = o.self; memset(&o, 0, sizeof(Payee)); return *this; } + LDKPayee* operator &() { return &self; } + LDKPayee* operator ->() { return &self; } + const LDKPayee* operator &() const { return &self; } + const LDKPayee* operator ->() const { return &self; } }; -class Bolt12InvoiceFeatures { +class RouteHint { private: - LDKBolt12InvoiceFeatures self; + LDKRouteHint self; public: - Bolt12InvoiceFeatures(const Bolt12InvoiceFeatures&) = delete; - Bolt12InvoiceFeatures(Bolt12InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); } - Bolt12InvoiceFeatures(LDKBolt12InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12InvoiceFeatures)); } - operator LDKBolt12InvoiceFeatures() && { LDKBolt12InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt12InvoiceFeatures)); return res; } - ~Bolt12InvoiceFeatures() { Bolt12InvoiceFeatures_free(self); } - Bolt12InvoiceFeatures& operator=(Bolt12InvoiceFeatures&& o) { Bolt12InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); return *this; } - LDKBolt12InvoiceFeatures* operator &() { return &self; } - LDKBolt12InvoiceFeatures* operator ->() { return &self; } - const LDKBolt12InvoiceFeatures* operator &() const { return &self; } - const LDKBolt12InvoiceFeatures* operator ->() const { return &self; } + RouteHint(const RouteHint&) = delete; + RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); } + RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); } + operator LDKRouteHint() && { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; } + ~RouteHint() { RouteHint_free(self); } + RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } + LDKRouteHint* operator &() { return &self; } + LDKRouteHint* operator ->() { return &self; } + const LDKRouteHint* operator &() const { return &self; } + const LDKRouteHint* operator ->() const { return &self; } }; -class BlindedHopFeatures { +class RouteHintHop { private: - LDKBlindedHopFeatures self; + LDKRouteHintHop self; public: - BlindedHopFeatures(const BlindedHopFeatures&) = delete; - BlindedHopFeatures(BlindedHopFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHopFeatures)); } - BlindedHopFeatures(LDKBlindedHopFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHopFeatures)); } - operator LDKBlindedHopFeatures() && { LDKBlindedHopFeatures res = self; memset(&self, 0, sizeof(LDKBlindedHopFeatures)); return res; } - ~BlindedHopFeatures() { BlindedHopFeatures_free(self); } - BlindedHopFeatures& operator=(BlindedHopFeatures&& o) { BlindedHopFeatures_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHopFeatures)); return *this; } - LDKBlindedHopFeatures* operator &() { return &self; } - LDKBlindedHopFeatures* operator ->() { return &self; } - const LDKBlindedHopFeatures* operator &() const { return &self; } - const LDKBlindedHopFeatures* operator ->() const { return &self; } + RouteHintHop(const RouteHintHop&) = delete; + RouteHintHop(RouteHintHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHintHop)); } + RouteHintHop(LDKRouteHintHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHintHop)); } + operator LDKRouteHintHop() && { LDKRouteHintHop res = self; memset(&self, 0, sizeof(LDKRouteHintHop)); return res; } + ~RouteHintHop() { RouteHintHop_free(self); } + RouteHintHop& operator=(RouteHintHop&& o) { RouteHintHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHintHop)); return *this; } + LDKRouteHintHop* operator &() { return &self; } + LDKRouteHintHop* operator ->() { return &self; } + const LDKRouteHintHop* operator &() const { return &self; } + const LDKRouteHintHop* operator ->() const { return &self; } }; -class ChannelTypeFeatures { +class Score { private: - LDKChannelTypeFeatures self; + LDKScore self; public: - ChannelTypeFeatures(const ChannelTypeFeatures&) = delete; - ChannelTypeFeatures(ChannelTypeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTypeFeatures)); } - ChannelTypeFeatures(LDKChannelTypeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTypeFeatures)); } - operator LDKChannelTypeFeatures() && { LDKChannelTypeFeatures res = self; memset(&self, 0, sizeof(LDKChannelTypeFeatures)); return res; } - ~ChannelTypeFeatures() { ChannelTypeFeatures_free(self); } - ChannelTypeFeatures& operator=(ChannelTypeFeatures&& o) { ChannelTypeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTypeFeatures)); return *this; } - LDKChannelTypeFeatures* operator &() { return &self; } - LDKChannelTypeFeatures* operator ->() { return &self; } - const LDKChannelTypeFeatures* operator &() const { return &self; } - const LDKChannelTypeFeatures* operator ->() const { return &self; } + Score(const Score&) = delete; + Score(Score&& o) : self(o.self) { memset(&o, 0, sizeof(Score)); } + Score(LDKScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKScore)); } + operator LDKScore() && { LDKScore res = self; memset(&self, 0, sizeof(LDKScore)); return res; } + ~Score() { Score_free(self); } + Score& operator=(Score&& o) { Score_free(self); self = o.self; memset(&o, 0, sizeof(Score)); return *this; } + LDKScore* operator &() { return &self; } + LDKScore* operator ->() { return &self; } + const LDKScore* operator &() const { return &self; } + const LDKScore* operator ->() const { return &self; } + /** + * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the + * given channel in the direction from `source` to `target`. + * + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. + */ + inline uint64_t channel_penalty_msat(uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params); + /** + * Handles updating channel penalties after failing to route through a channel. + */ + inline void payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); + /** + * Handles updating channel penalties after successfully routing along a path. + */ + inline void payment_path_successful(const struct LDKPath *NONNULL_PTR path); + /** + * Handles updating channel penalties after a probe over the given path failed. + */ + inline void probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); + /** + * Handles updating channel penalties after a probe over the given path succeeded. + */ + inline void probe_successful(const struct LDKPath *NONNULL_PTR path); }; -class PaymentPurpose { +class LockableScore { private: - LDKPaymentPurpose self; + LDKLockableScore self; public: - PaymentPurpose(const PaymentPurpose&) = delete; - PaymentPurpose(PaymentPurpose&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentPurpose)); } - PaymentPurpose(LDKPaymentPurpose&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentPurpose)); } - operator LDKPaymentPurpose() && { LDKPaymentPurpose res = self; memset(&self, 0, sizeof(LDKPaymentPurpose)); return res; } - ~PaymentPurpose() { PaymentPurpose_free(self); } - PaymentPurpose& operator=(PaymentPurpose&& o) { PaymentPurpose_free(self); self = o.self; memset(&o, 0, sizeof(PaymentPurpose)); return *this; } - LDKPaymentPurpose* operator &() { return &self; } - LDKPaymentPurpose* operator ->() { return &self; } - const LDKPaymentPurpose* operator &() const { return &self; } - const LDKPaymentPurpose* operator ->() const { return &self; } -}; -class PathFailure { -private: - LDKPathFailure self; -public: - PathFailure(const PathFailure&) = delete; - PathFailure(PathFailure&& o) : self(o.self) { memset(&o, 0, sizeof(PathFailure)); } - PathFailure(LDKPathFailure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPathFailure)); } - operator LDKPathFailure() && { LDKPathFailure res = self; memset(&self, 0, sizeof(LDKPathFailure)); return res; } - ~PathFailure() { PathFailure_free(self); } - PathFailure& operator=(PathFailure&& o) { PathFailure_free(self); self = o.self; memset(&o, 0, sizeof(PathFailure)); return *this; } - LDKPathFailure* operator &() { return &self; } - LDKPathFailure* operator ->() { return &self; } - const LDKPathFailure* operator &() const { return &self; } - const LDKPathFailure* operator ->() const { return &self; } + LockableScore(const LockableScore&) = delete; + LockableScore(LockableScore&& o) : self(o.self) { memset(&o, 0, sizeof(LockableScore)); } + LockableScore(LDKLockableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLockableScore)); } + operator LDKLockableScore() && { LDKLockableScore res = self; memset(&self, 0, sizeof(LDKLockableScore)); return res; } + ~LockableScore() { LockableScore_free(self); } + LockableScore& operator=(LockableScore&& o) { LockableScore_free(self); self = o.self; memset(&o, 0, sizeof(LockableScore)); return *this; } + LDKLockableScore* operator &() { return &self; } + LDKLockableScore* operator ->() { return &self; } + const LDKLockableScore* operator &() const { return &self; } + const LDKLockableScore* operator ->() const { return &self; } + /** + * Returns the locked scorer. + */ + inline LDK::Score lock(); }; -class ClosureReason { +class WriteableScore { private: - LDKClosureReason self; + LDKWriteableScore self; public: - ClosureReason(const ClosureReason&) = delete; - ClosureReason(ClosureReason&& o) : self(o.self) { memset(&o, 0, sizeof(ClosureReason)); } - ClosureReason(LDKClosureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosureReason)); } - operator LDKClosureReason() && { LDKClosureReason res = self; memset(&self, 0, sizeof(LDKClosureReason)); return res; } - ~ClosureReason() { ClosureReason_free(self); } - ClosureReason& operator=(ClosureReason&& o) { ClosureReason_free(self); self = o.self; memset(&o, 0, sizeof(ClosureReason)); return *this; } - LDKClosureReason* operator &() { return &self; } - LDKClosureReason* operator ->() { return &self; } - const LDKClosureReason* operator &() const { return &self; } - const LDKClosureReason* operator ->() const { return &self; } + WriteableScore(const WriteableScore&) = delete; + WriteableScore(WriteableScore&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableScore)); } + WriteableScore(LDKWriteableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableScore)); } + operator LDKWriteableScore() && { LDKWriteableScore res = self; memset(&self, 0, sizeof(LDKWriteableScore)); return res; } + ~WriteableScore() { WriteableScore_free(self); } + WriteableScore& operator=(WriteableScore&& o) { WriteableScore_free(self); self = o.self; memset(&o, 0, sizeof(WriteableScore)); return *this; } + LDKWriteableScore* operator &() { return &self; } + LDKWriteableScore* operator ->() { return &self; } + const LDKWriteableScore* operator &() const { return &self; } + const LDKWriteableScore* operator ->() const { return &self; } }; -class HTLCDestination { +class MultiThreadedLockableScore { private: - LDKHTLCDestination self; + LDKMultiThreadedLockableScore self; public: - HTLCDestination(const HTLCDestination&) = delete; - HTLCDestination(HTLCDestination&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCDestination)); } - HTLCDestination(LDKHTLCDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCDestination)); } - operator LDKHTLCDestination() && { LDKHTLCDestination res = self; memset(&self, 0, sizeof(LDKHTLCDestination)); return res; } - ~HTLCDestination() { HTLCDestination_free(self); } - HTLCDestination& operator=(HTLCDestination&& o) { HTLCDestination_free(self); self = o.self; memset(&o, 0, sizeof(HTLCDestination)); return *this; } - LDKHTLCDestination* operator &() { return &self; } - LDKHTLCDestination* operator ->() { return &self; } - const LDKHTLCDestination* operator &() const { return &self; } - const LDKHTLCDestination* operator ->() const { return &self; } + MultiThreadedLockableScore(const MultiThreadedLockableScore&) = delete; + MultiThreadedLockableScore(MultiThreadedLockableScore&& o) : self(o.self) { memset(&o, 0, sizeof(MultiThreadedLockableScore)); } + MultiThreadedLockableScore(LDKMultiThreadedLockableScore&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMultiThreadedLockableScore)); } + operator LDKMultiThreadedLockableScore() && { LDKMultiThreadedLockableScore res = self; memset(&self, 0, sizeof(LDKMultiThreadedLockableScore)); return res; } + ~MultiThreadedLockableScore() { MultiThreadedLockableScore_free(self); } + MultiThreadedLockableScore& operator=(MultiThreadedLockableScore&& o) { MultiThreadedLockableScore_free(self); self = o.self; memset(&o, 0, sizeof(MultiThreadedLockableScore)); return *this; } + LDKMultiThreadedLockableScore* operator &() { return &self; } + LDKMultiThreadedLockableScore* operator ->() { return &self; } + const LDKMultiThreadedLockableScore* operator &() const { return &self; } + const LDKMultiThreadedLockableScore* operator ->() const { return &self; } }; -class PaymentFailureReason { +class MultiThreadedScoreLock { private: - LDKPaymentFailureReason self; + LDKMultiThreadedScoreLock self; public: - PaymentFailureReason(const PaymentFailureReason&) = delete; - PaymentFailureReason(PaymentFailureReason&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentFailureReason)); } - PaymentFailureReason(LDKPaymentFailureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentFailureReason)); } - operator LDKPaymentFailureReason() && { LDKPaymentFailureReason res = self; memset(&self, 0, sizeof(LDKPaymentFailureReason)); return res; } - PaymentFailureReason& operator=(PaymentFailureReason&& o) { self = o.self; memset(&o, 0, sizeof(PaymentFailureReason)); return *this; } - LDKPaymentFailureReason* operator &() { return &self; } - LDKPaymentFailureReason* operator ->() { return &self; } - const LDKPaymentFailureReason* operator &() const { return &self; } - const LDKPaymentFailureReason* operator ->() const { return &self; } + MultiThreadedScoreLock(const MultiThreadedScoreLock&) = delete; + MultiThreadedScoreLock(MultiThreadedScoreLock&& o) : self(o.self) { memset(&o, 0, sizeof(MultiThreadedScoreLock)); } + MultiThreadedScoreLock(LDKMultiThreadedScoreLock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMultiThreadedScoreLock)); } + operator LDKMultiThreadedScoreLock() && { LDKMultiThreadedScoreLock res = self; memset(&self, 0, sizeof(LDKMultiThreadedScoreLock)); return res; } + ~MultiThreadedScoreLock() { MultiThreadedScoreLock_free(self); } + MultiThreadedScoreLock& operator=(MultiThreadedScoreLock&& o) { MultiThreadedScoreLock_free(self); self = o.self; memset(&o, 0, sizeof(MultiThreadedScoreLock)); return *this; } + LDKMultiThreadedScoreLock* operator &() { return &self; } + LDKMultiThreadedScoreLock* operator ->() { return &self; } + const LDKMultiThreadedScoreLock* operator &() const { return &self; } + const LDKMultiThreadedScoreLock* operator ->() const { return &self; } }; -class Event { +class ChannelUsage { private: - LDKEvent self; + LDKChannelUsage self; public: - Event(const Event&) = delete; - Event(Event&& o) : self(o.self) { memset(&o, 0, sizeof(Event)); } - Event(LDKEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEvent)); } - operator LDKEvent() && { LDKEvent res = self; memset(&self, 0, sizeof(LDKEvent)); return res; } - ~Event() { Event_free(self); } - Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } - LDKEvent* operator &() { return &self; } - LDKEvent* operator ->() { return &self; } - const LDKEvent* operator &() const { return &self; } - const LDKEvent* operator ->() const { return &self; } + ChannelUsage(const ChannelUsage&) = delete; + ChannelUsage(ChannelUsage&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUsage)); } + ChannelUsage(LDKChannelUsage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUsage)); } + operator LDKChannelUsage() && { LDKChannelUsage res = self; memset(&self, 0, sizeof(LDKChannelUsage)); return res; } + ~ChannelUsage() { ChannelUsage_free(self); } + ChannelUsage& operator=(ChannelUsage&& o) { ChannelUsage_free(self); self = o.self; memset(&o, 0, sizeof(ChannelUsage)); return *this; } + LDKChannelUsage* operator &() { return &self; } + LDKChannelUsage* operator ->() { return &self; } + const LDKChannelUsage* operator &() const { return &self; } + const LDKChannelUsage* operator ->() const { return &self; } }; -class MessageSendEvent { +class FixedPenaltyScorer { private: - LDKMessageSendEvent self; + LDKFixedPenaltyScorer self; public: - MessageSendEvent(const MessageSendEvent&) = delete; - MessageSendEvent(MessageSendEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEvent)); } - MessageSendEvent(LDKMessageSendEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEvent)); } - operator LDKMessageSendEvent() && { LDKMessageSendEvent res = self; memset(&self, 0, sizeof(LDKMessageSendEvent)); return res; } - ~MessageSendEvent() { MessageSendEvent_free(self); } - MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } - LDKMessageSendEvent* operator &() { return &self; } - LDKMessageSendEvent* operator ->() { return &self; } - const LDKMessageSendEvent* operator &() const { return &self; } - const LDKMessageSendEvent* operator ->() const { return &self; } + FixedPenaltyScorer(const FixedPenaltyScorer&) = delete; + FixedPenaltyScorer(FixedPenaltyScorer&& o) : self(o.self) { memset(&o, 0, sizeof(FixedPenaltyScorer)); } + FixedPenaltyScorer(LDKFixedPenaltyScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFixedPenaltyScorer)); } + operator LDKFixedPenaltyScorer() && { LDKFixedPenaltyScorer res = self; memset(&self, 0, sizeof(LDKFixedPenaltyScorer)); return res; } + ~FixedPenaltyScorer() { FixedPenaltyScorer_free(self); } + FixedPenaltyScorer& operator=(FixedPenaltyScorer&& o) { FixedPenaltyScorer_free(self); self = o.self; memset(&o, 0, sizeof(FixedPenaltyScorer)); return *this; } + LDKFixedPenaltyScorer* operator &() { return &self; } + LDKFixedPenaltyScorer* operator ->() { return &self; } + const LDKFixedPenaltyScorer* operator &() const { return &self; } + const LDKFixedPenaltyScorer* operator ->() const { return &self; } }; -class MessageSendEventsProvider { +class ProbabilisticScorer { private: - LDKMessageSendEventsProvider self; + LDKProbabilisticScorer self; public: - MessageSendEventsProvider(const MessageSendEventsProvider&) = delete; - MessageSendEventsProvider(MessageSendEventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEventsProvider)); } - MessageSendEventsProvider(LDKMessageSendEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEventsProvider)); } - operator LDKMessageSendEventsProvider() && { LDKMessageSendEventsProvider res = self; memset(&self, 0, sizeof(LDKMessageSendEventsProvider)); return res; } - ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } - MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } - LDKMessageSendEventsProvider* operator &() { return &self; } - LDKMessageSendEventsProvider* operator ->() { return &self; } - const LDKMessageSendEventsProvider* operator &() const { return &self; } - const LDKMessageSendEventsProvider* operator ->() const { return &self; } - /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. - */ - inline LDK::CVec_MessageSendEventZ get_and_clear_pending_msg_events(); + ProbabilisticScorer(const ProbabilisticScorer&) = delete; + ProbabilisticScorer(ProbabilisticScorer&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScorer)); } + ProbabilisticScorer(LDKProbabilisticScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScorer)); } + operator LDKProbabilisticScorer() && { LDKProbabilisticScorer res = self; memset(&self, 0, sizeof(LDKProbabilisticScorer)); return res; } + ~ProbabilisticScorer() { ProbabilisticScorer_free(self); } + ProbabilisticScorer& operator=(ProbabilisticScorer&& o) { ProbabilisticScorer_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScorer)); return *this; } + LDKProbabilisticScorer* operator &() { return &self; } + LDKProbabilisticScorer* operator ->() { return &self; } + const LDKProbabilisticScorer* operator &() const { return &self; } + const LDKProbabilisticScorer* operator ->() const { return &self; } }; -class OnionMessageProvider { +class ProbabilisticScoringFeeParameters { private: - LDKOnionMessageProvider self; + LDKProbabilisticScoringFeeParameters self; public: - OnionMessageProvider(const OnionMessageProvider&) = delete; - OnionMessageProvider(OnionMessageProvider&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageProvider)); } - OnionMessageProvider(LDKOnionMessageProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageProvider)); } - operator LDKOnionMessageProvider() && { LDKOnionMessageProvider res = self; memset(&self, 0, sizeof(LDKOnionMessageProvider)); return res; } - ~OnionMessageProvider() { OnionMessageProvider_free(self); } - OnionMessageProvider& operator=(OnionMessageProvider&& o) { OnionMessageProvider_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageProvider)); return *this; } - LDKOnionMessageProvider* operator &() { return &self; } - LDKOnionMessageProvider* operator ->() { return &self; } - const LDKOnionMessageProvider* operator &() const { return &self; } - const LDKOnionMessageProvider* operator ->() const { return &self; } - /** - * Gets the next pending onion message for the peer with the given node id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - inline LDK::OnionMessage next_onion_message_for_peer(struct LDKPublicKey peer_node_id); + ProbabilisticScoringFeeParameters(const ProbabilisticScoringFeeParameters&) = delete; + ProbabilisticScoringFeeParameters(ProbabilisticScoringFeeParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScoringFeeParameters)); } + ProbabilisticScoringFeeParameters(LDKProbabilisticScoringFeeParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScoringFeeParameters)); } + operator LDKProbabilisticScoringFeeParameters() && { LDKProbabilisticScoringFeeParameters res = self; memset(&self, 0, sizeof(LDKProbabilisticScoringFeeParameters)); return res; } + ~ProbabilisticScoringFeeParameters() { ProbabilisticScoringFeeParameters_free(self); } + ProbabilisticScoringFeeParameters& operator=(ProbabilisticScoringFeeParameters&& o) { ProbabilisticScoringFeeParameters_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScoringFeeParameters)); return *this; } + LDKProbabilisticScoringFeeParameters* operator &() { return &self; } + LDKProbabilisticScoringFeeParameters* operator ->() { return &self; } + const LDKProbabilisticScoringFeeParameters* operator &() const { return &self; } + const LDKProbabilisticScoringFeeParameters* operator ->() const { return &self; } }; -class EventsProvider { +class ProbabilisticScoringDecayParameters { private: - LDKEventsProvider self; + LDKProbabilisticScoringDecayParameters self; public: - EventsProvider(const EventsProvider&) = delete; - EventsProvider(EventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(EventsProvider)); } - EventsProvider(LDKEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventsProvider)); } - operator LDKEventsProvider() && { LDKEventsProvider res = self; memset(&self, 0, sizeof(LDKEventsProvider)); return res; } - ~EventsProvider() { EventsProvider_free(self); } - EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } - LDKEventsProvider* operator &() { return &self; } - LDKEventsProvider* operator ->() { return &self; } - const LDKEventsProvider* operator &() const { return &self; } - const LDKEventsProvider* operator ->() const { return &self; } - /** - * Processes any events generated since the last call using the given event handler. - * - * See the trait-level documentation for requirements. - */ - inline void process_pending_events(struct LDKEventHandler handler); + ProbabilisticScoringDecayParameters(const ProbabilisticScoringDecayParameters&) = delete; + ProbabilisticScoringDecayParameters(ProbabilisticScoringDecayParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScoringDecayParameters)); } + ProbabilisticScoringDecayParameters(LDKProbabilisticScoringDecayParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScoringDecayParameters)); } + operator LDKProbabilisticScoringDecayParameters() && { LDKProbabilisticScoringDecayParameters res = self; memset(&self, 0, sizeof(LDKProbabilisticScoringDecayParameters)); return res; } + ~ProbabilisticScoringDecayParameters() { ProbabilisticScoringDecayParameters_free(self); } + ProbabilisticScoringDecayParameters& operator=(ProbabilisticScoringDecayParameters&& o) { ProbabilisticScoringDecayParameters_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScoringDecayParameters)); return *this; } + LDKProbabilisticScoringDecayParameters* operator &() { return &self; } + LDKProbabilisticScoringDecayParameters* operator ->() { return &self; } + const LDKProbabilisticScoringDecayParameters* operator &() const { return &self; } + const LDKProbabilisticScoringDecayParameters* operator ->() const { return &self; } }; -class EventHandler { +class BestBlock { private: - LDKEventHandler self; + LDKBestBlock self; public: - EventHandler(const EventHandler&) = delete; - EventHandler(EventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(EventHandler)); } - EventHandler(LDKEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventHandler)); } - operator LDKEventHandler() && { LDKEventHandler res = self; memset(&self, 0, sizeof(LDKEventHandler)); return res; } - ~EventHandler() { EventHandler_free(self); } - EventHandler& operator=(EventHandler&& o) { EventHandler_free(self); self = o.self; memset(&o, 0, sizeof(EventHandler)); return *this; } - LDKEventHandler* operator &() { return &self; } - LDKEventHandler* operator ->() { return &self; } - const LDKEventHandler* operator &() const { return &self; } - const LDKEventHandler* operator ->() const { return &self; } - /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. - */ - inline void handle_event(struct LDKEvent event); + BestBlock(const BestBlock&) = delete; + BestBlock(BestBlock&& o) : self(o.self) { memset(&o, 0, sizeof(BestBlock)); } + BestBlock(LDKBestBlock&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBestBlock)); } + operator LDKBestBlock() && { LDKBestBlock res = self; memset(&self, 0, sizeof(LDKBestBlock)); return res; } + ~BestBlock() { BestBlock_free(self); } + BestBlock& operator=(BestBlock&& o) { BestBlock_free(self); self = o.self; memset(&o, 0, sizeof(BestBlock)); return *this; } + LDKBestBlock* operator &() { return &self; } + LDKBestBlock* operator ->() { return &self; } + const LDKBestBlock* operator &() const { return &self; } + const LDKBestBlock* operator ->() const { return &self; } }; -class Offer { +class Listen { private: - LDKOffer self; + LDKListen self; public: - Offer(const Offer&) = delete; - Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } - Offer(LDKOffer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffer)); } - operator LDKOffer() && { LDKOffer res = self; memset(&self, 0, sizeof(LDKOffer)); return res; } - ~Offer() { Offer_free(self); } - Offer& operator=(Offer&& o) { Offer_free(self); self = o.self; memset(&o, 0, sizeof(Offer)); return *this; } - LDKOffer* operator &() { return &self; } - LDKOffer* operator ->() { return &self; } - const LDKOffer* operator &() const { return &self; } - const LDKOffer* operator ->() const { return &self; } -}; -class Amount { + Listen(const Listen&) = delete; + Listen(Listen&& o) : self(o.self) { memset(&o, 0, sizeof(Listen)); } + Listen(LDKListen&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKListen)); } + operator LDKListen() && { LDKListen res = self; memset(&self, 0, sizeof(LDKListen)); return res; } + ~Listen() { Listen_free(self); } + Listen& operator=(Listen&& o) { Listen_free(self); self = o.self; memset(&o, 0, sizeof(Listen)); return *this; } + LDKListen* operator &() { return &self; } + LDKListen* operator ->() { return &self; } + const LDKListen* operator &() const { return &self; } + const LDKListen* operator ->() const { return &self; } + /** + * Notifies the listener that a block was added at the given height, with the transaction data + * possibly filtered. + */ + inline void filtered_block_connected(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Notifies the listener that a block was added at the given height. + */ + inline void block_connected(struct LDKu8slice block, uint32_t height); + /** + * Notifies the listener that a block was removed at the given height. + */ + inline void block_disconnected(const uint8_t (*header)[80], uint32_t height); +}; +class Confirm { private: - LDKAmount self; + LDKConfirm self; public: - Amount(const Amount&) = delete; - Amount(Amount&& o) : self(o.self) { memset(&o, 0, sizeof(Amount)); } - Amount(LDKAmount&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAmount)); } - operator LDKAmount() && { LDKAmount res = self; memset(&self, 0, sizeof(LDKAmount)); return res; } - ~Amount() { Amount_free(self); } - Amount& operator=(Amount&& o) { Amount_free(self); self = o.self; memset(&o, 0, sizeof(Amount)); return *this; } - LDKAmount* operator &() { return &self; } - LDKAmount* operator ->() { return &self; } - const LDKAmount* operator &() const { return &self; } - const LDKAmount* operator ->() const { return &self; } + Confirm(const Confirm&) = delete; + Confirm(Confirm&& o) : self(o.self) { memset(&o, 0, sizeof(Confirm)); } + Confirm(LDKConfirm&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirm)); } + operator LDKConfirm() && { LDKConfirm res = self; memset(&self, 0, sizeof(LDKConfirm)); return res; } + ~Confirm() { Confirm_free(self); } + Confirm& operator=(Confirm&& o) { Confirm_free(self); self = o.self; memset(&o, 0, sizeof(Confirm)); return *this; } + LDKConfirm* operator &() { return &self; } + LDKConfirm* operator ->() { return &self; } + const LDKConfirm* operator &() const { return &self; } + const LDKConfirm* operator ->() const { return &self; } + /** + * Notifies LDK of transactions confirmed in a block with a given header and height. + * + * Must be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Confirm#order + * [`best_block_updated`]: Self::best_block_updated + */ + inline void transactions_confirmed(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. + * + * Must be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain or if it is no longer confirmed in the block with the + * given block hash. Once called, the given transaction will not be returned + * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed + */ + inline void transaction_unconfirmed(const uint8_t (*txid)[32]); + /** + * Notifies LDK of an update to the best header connected at the given height. + * + * Must be called whenever a new chain tip becomes available. May be skipped for intermediary + * blocks. + */ + inline void best_block_updated(const uint8_t (*header)[80], uint32_t height); + /** + * Returns transactions that must be monitored for reorganization out of the chain along + * with the hash of the block as part of which it had been previously confirmed. + * + * Note that the returned `Option` might be `None` for channels created with LDK + * 0.0.112 and prior, in which case you need to manually track previous confirmations. + * + * Will include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Will not include any transactions + * passed to [`transaction_unconfirmed`], unless later reconfirmed. + * + * Must be called to determine the subset of transactions that must be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions must be + * given to [`transaction_unconfirmed`]. + * + * If any of the returned transactions are confirmed in a block other than the one with the + * given hash, they need to be unconfirmed and reconfirmed via [`transaction_unconfirmed`] and + * [`transactions_confirmed`], respectively. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + */ + inline LDK::CVec_C2Tuple_TxidCOption_BlockHashZZZ get_relevant_txids(); }; -class Quantity { +class ChannelMonitorUpdateStatus { private: - LDKQuantity self; + LDKChannelMonitorUpdateStatus self; public: - Quantity(const Quantity&) = delete; - Quantity(Quantity&& o) : self(o.self) { memset(&o, 0, sizeof(Quantity)); } - Quantity(LDKQuantity&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQuantity)); } - operator LDKQuantity() && { LDKQuantity res = self; memset(&self, 0, sizeof(LDKQuantity)); return res; } - ~Quantity() { Quantity_free(self); } - Quantity& operator=(Quantity&& o) { Quantity_free(self); self = o.self; memset(&o, 0, sizeof(Quantity)); return *this; } - LDKQuantity* operator &() { return &self; } - LDKQuantity* operator ->() { return &self; } - const LDKQuantity* operator &() const { return &self; } - const LDKQuantity* operator ->() const { return &self; } + ChannelMonitorUpdateStatus(const ChannelMonitorUpdateStatus&) = delete; + ChannelMonitorUpdateStatus(ChannelMonitorUpdateStatus&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdateStatus)); } + ChannelMonitorUpdateStatus(LDKChannelMonitorUpdateStatus&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdateStatus)); } + operator LDKChannelMonitorUpdateStatus() && { LDKChannelMonitorUpdateStatus res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdateStatus)); return res; } + ChannelMonitorUpdateStatus& operator=(ChannelMonitorUpdateStatus&& o) { self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdateStatus)); return *this; } + LDKChannelMonitorUpdateStatus* operator &() { return &self; } + LDKChannelMonitorUpdateStatus* operator ->() { return &self; } + const LDKChannelMonitorUpdateStatus* operator &() const { return &self; } + const LDKChannelMonitorUpdateStatus* operator ->() const { return &self; } }; -class NodeId { +class Watch { private: - LDKNodeId self; + LDKWatch self; public: - NodeId(const NodeId&) = delete; - NodeId(NodeId&& o) : self(o.self) { memset(&o, 0, sizeof(NodeId)); } - NodeId(LDKNodeId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeId)); } - operator LDKNodeId() && { LDKNodeId res = self; memset(&self, 0, sizeof(LDKNodeId)); return res; } - ~NodeId() { NodeId_free(self); } - NodeId& operator=(NodeId&& o) { NodeId_free(self); self = o.self; memset(&o, 0, sizeof(NodeId)); return *this; } - LDKNodeId* operator &() { return &self; } - LDKNodeId* operator ->() { return &self; } - const LDKNodeId* operator &() const { return &self; } - const LDKNodeId* operator ->() const { return &self; } + Watch(const Watch&) = delete; + Watch(Watch&& o) : self(o.self) { memset(&o, 0, sizeof(Watch)); } + Watch(LDKWatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatch)); } + operator LDKWatch() && { LDKWatch res = self; memset(&self, 0, sizeof(LDKWatch)); return res; } + ~Watch() { Watch_free(self); } + Watch& operator=(Watch&& o) { Watch_free(self); self = o.self; memset(&o, 0, sizeof(Watch)); return *this; } + LDKWatch* operator &() { return &self; } + LDKWatch* operator ->() { return &self; } + const LDKWatch* operator &() const { return &self; } + const LDKWatch* operator ->() const { return &self; } + /** + * Watches a channel identified by `funding_txo` using `monitor`. + * + * Implementations are responsible for watching the chain for the funding transaction along + * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * + * Note: this interface MUST error with [`ChannelMonitorUpdateStatus::PermanentFailure`] if + * the given `funding_txo` has previously been registered via `watch_channel`. + * + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + */ + inline LDK::ChannelMonitorUpdateStatus watch_channel(struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + /** + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateStatus`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + */ + inline LDK::ChannelMonitorUpdateStatus update_channel(struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update); + /** + * 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::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. + */ + inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events(); }; -class NetworkGraph { +class Filter { private: - LDKNetworkGraph self; + LDKFilter self; public: - NetworkGraph(const NetworkGraph&) = delete; - NetworkGraph(NetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkGraph)); } - NetworkGraph(LDKNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetworkGraph)); } - operator LDKNetworkGraph() && { LDKNetworkGraph res = self; memset(&self, 0, sizeof(LDKNetworkGraph)); return res; } - ~NetworkGraph() { NetworkGraph_free(self); } - NetworkGraph& operator=(NetworkGraph&& o) { NetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(NetworkGraph)); return *this; } - LDKNetworkGraph* operator &() { return &self; } - LDKNetworkGraph* operator ->() { return &self; } - const LDKNetworkGraph* operator &() const { return &self; } - const LDKNetworkGraph* operator ->() const { return &self; } + Filter(const Filter&) = delete; + Filter(Filter&& o) : self(o.self) { memset(&o, 0, sizeof(Filter)); } + Filter(LDKFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilter)); } + operator LDKFilter() && { LDKFilter res = self; memset(&self, 0, sizeof(LDKFilter)); return res; } + ~Filter() { Filter_free(self); } + Filter& operator=(Filter&& o) { Filter_free(self); self = o.self; memset(&o, 0, sizeof(Filter)); return *this; } + LDKFilter* operator &() { return &self; } + LDKFilter* operator ->() { return &self; } + const LDKFilter* operator &() const { return &self; } + const LDKFilter* operator ->() const { return &self; } + /** + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. + */ + inline void register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + /** + * Registers interest in spends of a transaction output. + * + * Note that this method might be called during processing of a new block. You therefore need + * to ensure that also dependent output spents within an already connected block are correctly + * handled, e.g., by re-scanning the block in question whenever new outputs have been + * registered mid-processing. + */ + inline void register_output(struct LDKWatchedOutput output); }; -class ReadOnlyNetworkGraph { +class WatchedOutput { private: - LDKReadOnlyNetworkGraph self; + LDKWatchedOutput self; public: - ReadOnlyNetworkGraph(const ReadOnlyNetworkGraph&) = delete; - ReadOnlyNetworkGraph(ReadOnlyNetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); } - ReadOnlyNetworkGraph(LDKReadOnlyNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReadOnlyNetworkGraph)); } - operator LDKReadOnlyNetworkGraph() && { LDKReadOnlyNetworkGraph res = self; memset(&self, 0, sizeof(LDKReadOnlyNetworkGraph)); return res; } - ~ReadOnlyNetworkGraph() { ReadOnlyNetworkGraph_free(self); } - ReadOnlyNetworkGraph& operator=(ReadOnlyNetworkGraph&& o) { ReadOnlyNetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); return *this; } - LDKReadOnlyNetworkGraph* operator &() { return &self; } - LDKReadOnlyNetworkGraph* operator ->() { return &self; } - const LDKReadOnlyNetworkGraph* operator &() const { return &self; } - const LDKReadOnlyNetworkGraph* operator ->() const { return &self; } + WatchedOutput(const WatchedOutput&) = delete; + WatchedOutput(WatchedOutput&& o) : self(o.self) { memset(&o, 0, sizeof(WatchedOutput)); } + WatchedOutput(LDKWatchedOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatchedOutput)); } + operator LDKWatchedOutput() && { LDKWatchedOutput res = self; memset(&self, 0, sizeof(LDKWatchedOutput)); return res; } + ~WatchedOutput() { WatchedOutput_free(self); } + WatchedOutput& operator=(WatchedOutput&& o) { WatchedOutput_free(self); self = o.self; memset(&o, 0, sizeof(WatchedOutput)); return *this; } + LDKWatchedOutput* operator &() { return &self; } + LDKWatchedOutput* operator ->() { return &self; } + const LDKWatchedOutput* operator &() const { return &self; } + const LDKWatchedOutput* operator ->() const { return &self; } }; -class NetworkUpdate { +class InitFeatures { private: - LDKNetworkUpdate self; + LDKInitFeatures self; public: - NetworkUpdate(const NetworkUpdate&) = delete; - NetworkUpdate(NetworkUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkUpdate)); } + InitFeatures(const InitFeatures&) = delete; + InitFeatures(InitFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InitFeatures)); } + InitFeatures(LDKInitFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInitFeatures)); } + operator LDKInitFeatures() && { LDKInitFeatures res = self; memset(&self, 0, sizeof(LDKInitFeatures)); return res; } + ~InitFeatures() { InitFeatures_free(self); } + InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } + LDKInitFeatures* operator &() { return &self; } + LDKInitFeatures* operator ->() { return &self; } + const LDKInitFeatures* operator &() const { return &self; } + const LDKInitFeatures* operator ->() const { return &self; } +}; +class NodeFeatures { +private: + LDKNodeFeatures self; +public: + NodeFeatures(const NodeFeatures&) = delete; + NodeFeatures(NodeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(NodeFeatures)); } + NodeFeatures(LDKNodeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeFeatures)); } + operator LDKNodeFeatures() && { LDKNodeFeatures res = self; memset(&self, 0, sizeof(LDKNodeFeatures)); return res; } + ~NodeFeatures() { NodeFeatures_free(self); } + NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } + LDKNodeFeatures* operator &() { return &self; } + LDKNodeFeatures* operator ->() { return &self; } + const LDKNodeFeatures* operator &() const { return &self; } + const LDKNodeFeatures* operator ->() const { return &self; } +}; +class ChannelFeatures { +private: + LDKChannelFeatures self; +public: + ChannelFeatures(const ChannelFeatures&) = delete; + ChannelFeatures(ChannelFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelFeatures)); } + ChannelFeatures(LDKChannelFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelFeatures)); } + operator LDKChannelFeatures() && { LDKChannelFeatures res = self; memset(&self, 0, sizeof(LDKChannelFeatures)); return res; } + ~ChannelFeatures() { ChannelFeatures_free(self); } + ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } + LDKChannelFeatures* operator &() { return &self; } + LDKChannelFeatures* operator ->() { return &self; } + const LDKChannelFeatures* operator &() const { return &self; } + const LDKChannelFeatures* operator ->() const { return &self; } +}; +class Bolt11InvoiceFeatures { +private: + LDKBolt11InvoiceFeatures self; +public: + Bolt11InvoiceFeatures(const Bolt11InvoiceFeatures&) = delete; + Bolt11InvoiceFeatures(Bolt11InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); } + Bolt11InvoiceFeatures(LDKBolt11InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11InvoiceFeatures)); } + operator LDKBolt11InvoiceFeatures() && { LDKBolt11InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt11InvoiceFeatures)); return res; } + ~Bolt11InvoiceFeatures() { Bolt11InvoiceFeatures_free(self); } + Bolt11InvoiceFeatures& operator=(Bolt11InvoiceFeatures&& o) { Bolt11InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); return *this; } + LDKBolt11InvoiceFeatures* operator &() { return &self; } + LDKBolt11InvoiceFeatures* operator ->() { return &self; } + const LDKBolt11InvoiceFeatures* operator &() const { return &self; } + const LDKBolt11InvoiceFeatures* operator ->() const { return &self; } +}; +class OfferFeatures { +private: + LDKOfferFeatures self; +public: + OfferFeatures(const OfferFeatures&) = delete; + OfferFeatures(OfferFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(OfferFeatures)); } + OfferFeatures(LDKOfferFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferFeatures)); } + operator LDKOfferFeatures() && { LDKOfferFeatures res = self; memset(&self, 0, sizeof(LDKOfferFeatures)); return res; } + ~OfferFeatures() { OfferFeatures_free(self); } + OfferFeatures& operator=(OfferFeatures&& o) { OfferFeatures_free(self); self = o.self; memset(&o, 0, sizeof(OfferFeatures)); return *this; } + LDKOfferFeatures* operator &() { return &self; } + LDKOfferFeatures* operator ->() { return &self; } + const LDKOfferFeatures* operator &() const { return &self; } + const LDKOfferFeatures* operator ->() const { return &self; } +}; +class InvoiceRequestFeatures { +private: + LDKInvoiceRequestFeatures self; +public: + InvoiceRequestFeatures(const InvoiceRequestFeatures&) = delete; + InvoiceRequestFeatures(InvoiceRequestFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestFeatures)); } + InvoiceRequestFeatures(LDKInvoiceRequestFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestFeatures)); } + operator LDKInvoiceRequestFeatures() && { LDKInvoiceRequestFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceRequestFeatures)); return res; } + ~InvoiceRequestFeatures() { InvoiceRequestFeatures_free(self); } + InvoiceRequestFeatures& operator=(InvoiceRequestFeatures&& o) { InvoiceRequestFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestFeatures)); return *this; } + LDKInvoiceRequestFeatures* operator &() { return &self; } + LDKInvoiceRequestFeatures* operator ->() { return &self; } + const LDKInvoiceRequestFeatures* operator &() const { return &self; } + const LDKInvoiceRequestFeatures* operator ->() const { return &self; } +}; +class Bolt12InvoiceFeatures { +private: + LDKBolt12InvoiceFeatures self; +public: + Bolt12InvoiceFeatures(const Bolt12InvoiceFeatures&) = delete; + Bolt12InvoiceFeatures(Bolt12InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); } + Bolt12InvoiceFeatures(LDKBolt12InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12InvoiceFeatures)); } + operator LDKBolt12InvoiceFeatures() && { LDKBolt12InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt12InvoiceFeatures)); return res; } + ~Bolt12InvoiceFeatures() { Bolt12InvoiceFeatures_free(self); } + Bolt12InvoiceFeatures& operator=(Bolt12InvoiceFeatures&& o) { Bolt12InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); return *this; } + LDKBolt12InvoiceFeatures* operator &() { return &self; } + LDKBolt12InvoiceFeatures* operator ->() { return &self; } + const LDKBolt12InvoiceFeatures* operator &() const { return &self; } + const LDKBolt12InvoiceFeatures* operator ->() const { return &self; } +}; +class BlindedHopFeatures { +private: + LDKBlindedHopFeatures self; +public: + BlindedHopFeatures(const BlindedHopFeatures&) = delete; + BlindedHopFeatures(BlindedHopFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHopFeatures)); } + BlindedHopFeatures(LDKBlindedHopFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHopFeatures)); } + operator LDKBlindedHopFeatures() && { LDKBlindedHopFeatures res = self; memset(&self, 0, sizeof(LDKBlindedHopFeatures)); return res; } + ~BlindedHopFeatures() { BlindedHopFeatures_free(self); } + BlindedHopFeatures& operator=(BlindedHopFeatures&& o) { BlindedHopFeatures_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHopFeatures)); return *this; } + LDKBlindedHopFeatures* operator &() { return &self; } + LDKBlindedHopFeatures* operator ->() { return &self; } + const LDKBlindedHopFeatures* operator &() const { return &self; } + const LDKBlindedHopFeatures* operator ->() const { return &self; } +}; +class ChannelTypeFeatures { +private: + LDKChannelTypeFeatures self; +public: + ChannelTypeFeatures(const ChannelTypeFeatures&) = delete; + ChannelTypeFeatures(ChannelTypeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTypeFeatures)); } + ChannelTypeFeatures(LDKChannelTypeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTypeFeatures)); } + operator LDKChannelTypeFeatures() && { LDKChannelTypeFeatures res = self; memset(&self, 0, sizeof(LDKChannelTypeFeatures)); return res; } + ~ChannelTypeFeatures() { ChannelTypeFeatures_free(self); } + ChannelTypeFeatures& operator=(ChannelTypeFeatures&& o) { ChannelTypeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTypeFeatures)); return *this; } + LDKChannelTypeFeatures* operator &() { return &self; } + LDKChannelTypeFeatures* operator ->() { return &self; } + const LDKChannelTypeFeatures* operator &() const { return &self; } + const LDKChannelTypeFeatures* operator ->() const { return &self; } +}; +class Offer { +private: + LDKOffer self; +public: + Offer(const Offer&) = delete; + Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } + Offer(LDKOffer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffer)); } + operator LDKOffer() && { LDKOffer res = self; memset(&self, 0, sizeof(LDKOffer)); return res; } + ~Offer() { Offer_free(self); } + Offer& operator=(Offer&& o) { Offer_free(self); self = o.self; memset(&o, 0, sizeof(Offer)); return *this; } + LDKOffer* operator &() { return &self; } + LDKOffer* operator ->() { return &self; } + const LDKOffer* operator &() const { return &self; } + const LDKOffer* operator ->() const { return &self; } +}; +class Amount { +private: + LDKAmount self; +public: + Amount(const Amount&) = delete; + Amount(Amount&& o) : self(o.self) { memset(&o, 0, sizeof(Amount)); } + Amount(LDKAmount&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAmount)); } + operator LDKAmount() && { LDKAmount res = self; memset(&self, 0, sizeof(LDKAmount)); return res; } + ~Amount() { Amount_free(self); } + Amount& operator=(Amount&& o) { Amount_free(self); self = o.self; memset(&o, 0, sizeof(Amount)); return *this; } + LDKAmount* operator &() { return &self; } + LDKAmount* operator ->() { return &self; } + const LDKAmount* operator &() const { return &self; } + const LDKAmount* operator ->() const { return &self; } +}; +class Quantity { +private: + LDKQuantity self; +public: + Quantity(const Quantity&) = delete; + Quantity(Quantity&& o) : self(o.self) { memset(&o, 0, sizeof(Quantity)); } + Quantity(LDKQuantity&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQuantity)); } + operator LDKQuantity() && { LDKQuantity res = self; memset(&self, 0, sizeof(LDKQuantity)); return res; } + ~Quantity() { Quantity_free(self); } + Quantity& operator=(Quantity&& o) { Quantity_free(self); self = o.self; memset(&o, 0, sizeof(Quantity)); return *this; } + LDKQuantity* operator &() { return &self; } + LDKQuantity* operator ->() { return &self; } + const LDKQuantity* operator &() const { return &self; } + const LDKQuantity* operator ->() const { return &self; } +}; +class NodeId { +private: + LDKNodeId self; +public: + NodeId(const NodeId&) = delete; + NodeId(NodeId&& o) : self(o.self) { memset(&o, 0, sizeof(NodeId)); } + NodeId(LDKNodeId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeId)); } + operator LDKNodeId() && { LDKNodeId res = self; memset(&self, 0, sizeof(LDKNodeId)); return res; } + ~NodeId() { NodeId_free(self); } + NodeId& operator=(NodeId&& o) { NodeId_free(self); self = o.self; memset(&o, 0, sizeof(NodeId)); return *this; } + LDKNodeId* operator &() { return &self; } + LDKNodeId* operator ->() { return &self; } + const LDKNodeId* operator &() const { return &self; } + const LDKNodeId* operator ->() const { return &self; } +}; +class NetworkGraph { +private: + LDKNetworkGraph self; +public: + NetworkGraph(const NetworkGraph&) = delete; + NetworkGraph(NetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkGraph)); } + NetworkGraph(LDKNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetworkGraph)); } + operator LDKNetworkGraph() && { LDKNetworkGraph res = self; memset(&self, 0, sizeof(LDKNetworkGraph)); return res; } + ~NetworkGraph() { NetworkGraph_free(self); } + NetworkGraph& operator=(NetworkGraph&& o) { NetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(NetworkGraph)); return *this; } + LDKNetworkGraph* operator &() { return &self; } + LDKNetworkGraph* operator ->() { return &self; } + const LDKNetworkGraph* operator &() const { return &self; } + const LDKNetworkGraph* operator ->() const { return &self; } +}; +class ReadOnlyNetworkGraph { +private: + LDKReadOnlyNetworkGraph self; +public: + ReadOnlyNetworkGraph(const ReadOnlyNetworkGraph&) = delete; + ReadOnlyNetworkGraph(ReadOnlyNetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); } + ReadOnlyNetworkGraph(LDKReadOnlyNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReadOnlyNetworkGraph)); } + operator LDKReadOnlyNetworkGraph() && { LDKReadOnlyNetworkGraph res = self; memset(&self, 0, sizeof(LDKReadOnlyNetworkGraph)); return res; } + ~ReadOnlyNetworkGraph() { ReadOnlyNetworkGraph_free(self); } + ReadOnlyNetworkGraph& operator=(ReadOnlyNetworkGraph&& o) { ReadOnlyNetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); return *this; } + LDKReadOnlyNetworkGraph* operator &() { return &self; } + LDKReadOnlyNetworkGraph* operator ->() { return &self; } + const LDKReadOnlyNetworkGraph* operator &() const { return &self; } + const LDKReadOnlyNetworkGraph* operator ->() const { return &self; } +}; +class NetworkUpdate { +private: + LDKNetworkUpdate self; +public: + NetworkUpdate(const NetworkUpdate&) = delete; + NetworkUpdate(NetworkUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkUpdate)); } NetworkUpdate(LDKNetworkUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetworkUpdate)); } operator LDKNetworkUpdate() && { LDKNetworkUpdate res = self; memset(&self, 0, sizeof(LDKNetworkUpdate)); return res; } ~NetworkUpdate() { NetworkUpdate_free(self); } @@ -2130,2572 +2225,3292 @@ public: const LDKNodeInfo* operator &() const { return &self; } const LDKNodeInfo* operator ->() const { return &self; } }; -class DelayedPaymentOutputDescriptor { +class ChannelDerivationParameters { +private: + LDKChannelDerivationParameters self; +public: + ChannelDerivationParameters(const ChannelDerivationParameters&) = delete; + ChannelDerivationParameters(ChannelDerivationParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDerivationParameters)); } + ChannelDerivationParameters(LDKChannelDerivationParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDerivationParameters)); } + operator LDKChannelDerivationParameters() && { LDKChannelDerivationParameters res = self; memset(&self, 0, sizeof(LDKChannelDerivationParameters)); return res; } + ~ChannelDerivationParameters() { ChannelDerivationParameters_free(self); } + ChannelDerivationParameters& operator=(ChannelDerivationParameters&& o) { ChannelDerivationParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDerivationParameters)); return *this; } + LDKChannelDerivationParameters* operator &() { return &self; } + LDKChannelDerivationParameters* operator ->() { return &self; } + const LDKChannelDerivationParameters* operator &() const { return &self; } + const LDKChannelDerivationParameters* operator ->() const { return &self; } +}; +class AnchorDescriptor { +private: + LDKAnchorDescriptor self; +public: + AnchorDescriptor(const AnchorDescriptor&) = delete; + AnchorDescriptor(AnchorDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(AnchorDescriptor)); } + AnchorDescriptor(LDKAnchorDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAnchorDescriptor)); } + operator LDKAnchorDescriptor() && { LDKAnchorDescriptor res = self; memset(&self, 0, sizeof(LDKAnchorDescriptor)); return res; } + ~AnchorDescriptor() { AnchorDescriptor_free(self); } + AnchorDescriptor& operator=(AnchorDescriptor&& o) { AnchorDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(AnchorDescriptor)); return *this; } + LDKAnchorDescriptor* operator &() { return &self; } + LDKAnchorDescriptor* operator ->() { return &self; } + const LDKAnchorDescriptor* operator &() const { return &self; } + const LDKAnchorDescriptor* operator ->() const { return &self; } +}; +class HTLCDescriptor { +private: + LDKHTLCDescriptor self; +public: + HTLCDescriptor(const HTLCDescriptor&) = delete; + HTLCDescriptor(HTLCDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCDescriptor)); } + HTLCDescriptor(LDKHTLCDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCDescriptor)); } + operator LDKHTLCDescriptor() && { LDKHTLCDescriptor res = self; memset(&self, 0, sizeof(LDKHTLCDescriptor)); return res; } + ~HTLCDescriptor() { HTLCDescriptor_free(self); } + HTLCDescriptor& operator=(HTLCDescriptor&& o) { HTLCDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(HTLCDescriptor)); return *this; } + LDKHTLCDescriptor* operator &() { return &self; } + LDKHTLCDescriptor* operator ->() { return &self; } + const LDKHTLCDescriptor* operator &() const { return &self; } + const LDKHTLCDescriptor* operator ->() const { return &self; } +}; +class BumpTransactionEvent { +private: + LDKBumpTransactionEvent self; +public: + BumpTransactionEvent(const BumpTransactionEvent&) = delete; + BumpTransactionEvent(BumpTransactionEvent&& o) : self(o.self) { memset(&o, 0, sizeof(BumpTransactionEvent)); } + BumpTransactionEvent(LDKBumpTransactionEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBumpTransactionEvent)); } + operator LDKBumpTransactionEvent() && { LDKBumpTransactionEvent res = self; memset(&self, 0, sizeof(LDKBumpTransactionEvent)); return res; } + ~BumpTransactionEvent() { BumpTransactionEvent_free(self); } + BumpTransactionEvent& operator=(BumpTransactionEvent&& o) { BumpTransactionEvent_free(self); self = o.self; memset(&o, 0, sizeof(BumpTransactionEvent)); return *this; } + LDKBumpTransactionEvent* operator &() { return &self; } + LDKBumpTransactionEvent* operator ->() { return &self; } + const LDKBumpTransactionEvent* operator &() const { return &self; } + const LDKBumpTransactionEvent* operator ->() const { return &self; } +}; +class Input { +private: + LDKInput self; +public: + Input(const Input&) = delete; + Input(Input&& o) : self(o.self) { memset(&o, 0, sizeof(Input)); } + Input(LDKInput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInput)); } + operator LDKInput() && { LDKInput res = self; memset(&self, 0, sizeof(LDKInput)); return res; } + ~Input() { Input_free(self); } + Input& operator=(Input&& o) { Input_free(self); self = o.self; memset(&o, 0, sizeof(Input)); return *this; } + LDKInput* operator &() { return &self; } + LDKInput* operator ->() { return &self; } + const LDKInput* operator &() const { return &self; } + const LDKInput* operator ->() const { return &self; } +}; +class Utxo { +private: + LDKUtxo self; +public: + Utxo(const Utxo&) = delete; + Utxo(Utxo&& o) : self(o.self) { memset(&o, 0, sizeof(Utxo)); } + Utxo(LDKUtxo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxo)); } + operator LDKUtxo() && { LDKUtxo res = self; memset(&self, 0, sizeof(LDKUtxo)); return res; } + ~Utxo() { Utxo_free(self); } + Utxo& operator=(Utxo&& o) { Utxo_free(self); self = o.self; memset(&o, 0, sizeof(Utxo)); return *this; } + LDKUtxo* operator &() { return &self; } + LDKUtxo* operator ->() { return &self; } + const LDKUtxo* operator &() const { return &self; } + const LDKUtxo* operator ->() const { return &self; } +}; +class CoinSelection { +private: + LDKCoinSelection self; +public: + CoinSelection(const CoinSelection&) = delete; + CoinSelection(CoinSelection&& o) : self(o.self) { memset(&o, 0, sizeof(CoinSelection)); } + CoinSelection(LDKCoinSelection&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCoinSelection)); } + operator LDKCoinSelection() && { LDKCoinSelection res = self; memset(&self, 0, sizeof(LDKCoinSelection)); return res; } + ~CoinSelection() { CoinSelection_free(self); } + CoinSelection& operator=(CoinSelection&& o) { CoinSelection_free(self); self = o.self; memset(&o, 0, sizeof(CoinSelection)); return *this; } + LDKCoinSelection* operator &() { return &self; } + LDKCoinSelection* operator ->() { return &self; } + const LDKCoinSelection* operator &() const { return &self; } + const LDKCoinSelection* operator ->() const { return &self; } +}; +class CoinSelectionSource { +private: + LDKCoinSelectionSource self; +public: + CoinSelectionSource(const CoinSelectionSource&) = delete; + CoinSelectionSource(CoinSelectionSource&& o) : self(o.self) { memset(&o, 0, sizeof(CoinSelectionSource)); } + CoinSelectionSource(LDKCoinSelectionSource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCoinSelectionSource)); } + operator LDKCoinSelectionSource() && { LDKCoinSelectionSource res = self; memset(&self, 0, sizeof(LDKCoinSelectionSource)); return res; } + ~CoinSelectionSource() { CoinSelectionSource_free(self); } + CoinSelectionSource& operator=(CoinSelectionSource&& o) { CoinSelectionSource_free(self); self = o.self; memset(&o, 0, sizeof(CoinSelectionSource)); return *this; } + LDKCoinSelectionSource* operator &() { return &self; } + LDKCoinSelectionSource* operator ->() { return &self; } + const LDKCoinSelectionSource* operator &() const { return &self; } + const LDKCoinSelectionSource* operator ->() const { return &self; } + /** + * Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are + * available to spend. Implementations are free to pick their coin selection algorithm of + * choice, as long as the following requirements are met: + * + * 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction + * throughout coin selection, but must not be returned as part of the result. + * 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction + * throughout coin selection. In some cases, like when funding an anchor transaction, this + * set is empty. Implementations should ensure they handle this correctly on their end, + * e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be + * provided, in which case a zero-value empty OP_RETURN output can be used instead. + * 3. Enough inputs must be selected/contributed for the resulting transaction (including the + * inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`. + * + * Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of + * the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require + * providing the full input weight. Failing to do so may lead to underestimating fee bumps and + * delaying block inclusion. + * + * The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they + * can be re-used within new fee-bumped iterations of the original claiming transaction, + * ensuring that claims don't double spend each other. If a specific `claim_id` has never had a + * transaction associated with it, and all of the available UTXOs have already been assigned to + * other claims, implementations must be willing to double spend their UTXOs. The choice of + * which UTXOs to double spend is left to the implementation, but it must strive to keep the + * set of other claims being double spent to a minimum. + */ + inline LDK::CResult_CoinSelectionNoneZ select_confirmed_utxos(struct LDKThirtyTwoBytes claim_id, struct LDKCVec_InputZ must_spend, struct LDKCVec_TxOutZ must_pay_to, uint32_t target_feerate_sat_per_1000_weight); + /** + * Signs and provides the full witness for all inputs within the transaction known to the + * trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]). + */ + inline LDK::CResult_TransactionNoneZ sign_tx(struct LDKTransaction tx); +}; +class WalletSource { +private: + LDKWalletSource self; +public: + WalletSource(const WalletSource&) = delete; + WalletSource(WalletSource&& o) : self(o.self) { memset(&o, 0, sizeof(WalletSource)); } + WalletSource(LDKWalletSource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWalletSource)); } + operator LDKWalletSource() && { LDKWalletSource res = self; memset(&self, 0, sizeof(LDKWalletSource)); return res; } + ~WalletSource() { WalletSource_free(self); } + WalletSource& operator=(WalletSource&& o) { WalletSource_free(self); self = o.self; memset(&o, 0, sizeof(WalletSource)); return *this; } + LDKWalletSource* operator &() { return &self; } + LDKWalletSource* operator ->() { return &self; } + const LDKWalletSource* operator &() const { return &self; } + const LDKWalletSource* operator ->() const { return &self; } + /** + * Returns all UTXOs, with at least 1 confirmation each, that are available to spend. + */ + inline LDK::CResult_CVec_UtxoZNoneZ list_confirmed_utxos(); + /** + * Returns a script to use for change above dust resulting from a successful coin selection + * attempt. + */ + inline LDK::CResult_ScriptNoneZ get_change_script(); + /** + * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within + * the transaction known to the wallet (i.e., any provided via + * [`WalletSource::list_confirmed_utxos`]). + */ + inline LDK::CResult_TransactionNoneZ sign_tx(struct LDKTransaction tx); +}; +class Wallet { +private: + LDKWallet self; +public: + Wallet(const Wallet&) = delete; + Wallet(Wallet&& o) : self(o.self) { memset(&o, 0, sizeof(Wallet)); } + Wallet(LDKWallet&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWallet)); } + operator LDKWallet() && { LDKWallet res = self; memset(&self, 0, sizeof(LDKWallet)); return res; } + ~Wallet() { Wallet_free(self); } + Wallet& operator=(Wallet&& o) { Wallet_free(self); self = o.self; memset(&o, 0, sizeof(Wallet)); return *this; } + LDKWallet* operator &() { return &self; } + LDKWallet* operator ->() { return &self; } + const LDKWallet* operator &() const { return &self; } + const LDKWallet* operator ->() const { return &self; } +}; +class BumpTransactionEventHandler { +private: + LDKBumpTransactionEventHandler self; +public: + BumpTransactionEventHandler(const BumpTransactionEventHandler&) = delete; + BumpTransactionEventHandler(BumpTransactionEventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(BumpTransactionEventHandler)); } + BumpTransactionEventHandler(LDKBumpTransactionEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBumpTransactionEventHandler)); } + operator LDKBumpTransactionEventHandler() && { LDKBumpTransactionEventHandler res = self; memset(&self, 0, sizeof(LDKBumpTransactionEventHandler)); return res; } + ~BumpTransactionEventHandler() { BumpTransactionEventHandler_free(self); } + BumpTransactionEventHandler& operator=(BumpTransactionEventHandler&& o) { BumpTransactionEventHandler_free(self); self = o.self; memset(&o, 0, sizeof(BumpTransactionEventHandler)); return *this; } + LDKBumpTransactionEventHandler* operator &() { return &self; } + LDKBumpTransactionEventHandler* operator ->() { return &self; } + const LDKBumpTransactionEventHandler* operator &() const { return &self; } + const LDKBumpTransactionEventHandler* operator ->() const { return &self; } +}; +class FailureCode { private: - LDKDelayedPaymentOutputDescriptor self; + LDKFailureCode self; public: - DelayedPaymentOutputDescriptor(const DelayedPaymentOutputDescriptor&) = delete; - DelayedPaymentOutputDescriptor(DelayedPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); } - DelayedPaymentOutputDescriptor(LDKDelayedPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); } - operator LDKDelayedPaymentOutputDescriptor() && { LDKDelayedPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKDelayedPaymentOutputDescriptor)); return res; } - ~DelayedPaymentOutputDescriptor() { DelayedPaymentOutputDescriptor_free(self); } - DelayedPaymentOutputDescriptor& operator=(DelayedPaymentOutputDescriptor&& o) { DelayedPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(DelayedPaymentOutputDescriptor)); return *this; } - LDKDelayedPaymentOutputDescriptor* operator &() { return &self; } - LDKDelayedPaymentOutputDescriptor* operator ->() { return &self; } - const LDKDelayedPaymentOutputDescriptor* operator &() const { return &self; } - const LDKDelayedPaymentOutputDescriptor* operator ->() const { return &self; } + FailureCode(const FailureCode&) = delete; + FailureCode(FailureCode&& o) : self(o.self) { memset(&o, 0, sizeof(FailureCode)); } + FailureCode(LDKFailureCode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFailureCode)); } + operator LDKFailureCode() && { LDKFailureCode res = self; memset(&self, 0, sizeof(LDKFailureCode)); return res; } + FailureCode& operator=(FailureCode&& o) { self = o.self; memset(&o, 0, sizeof(FailureCode)); return *this; } + LDKFailureCode* operator &() { return &self; } + LDKFailureCode* operator ->() { return &self; } + const LDKFailureCode* operator &() const { return &self; } + const LDKFailureCode* operator ->() const { return &self; } }; -class StaticPaymentOutputDescriptor { +class ChannelManager { private: - LDKStaticPaymentOutputDescriptor self; + LDKChannelManager self; public: - StaticPaymentOutputDescriptor(const StaticPaymentOutputDescriptor&) = delete; - StaticPaymentOutputDescriptor(StaticPaymentOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); } - StaticPaymentOutputDescriptor(LDKStaticPaymentOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); } - operator LDKStaticPaymentOutputDescriptor() && { LDKStaticPaymentOutputDescriptor res = self; memset(&self, 0, sizeof(LDKStaticPaymentOutputDescriptor)); return res; } - ~StaticPaymentOutputDescriptor() { StaticPaymentOutputDescriptor_free(self); } - StaticPaymentOutputDescriptor& operator=(StaticPaymentOutputDescriptor&& o) { StaticPaymentOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(StaticPaymentOutputDescriptor)); return *this; } - LDKStaticPaymentOutputDescriptor* operator &() { return &self; } - LDKStaticPaymentOutputDescriptor* operator ->() { return &self; } - const LDKStaticPaymentOutputDescriptor* operator &() const { return &self; } - const LDKStaticPaymentOutputDescriptor* operator ->() const { return &self; } + ChannelManager(const ChannelManager&) = delete; + ChannelManager(ChannelManager&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManager)); } + ChannelManager(LDKChannelManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManager)); } + operator LDKChannelManager() && { LDKChannelManager res = self; memset(&self, 0, sizeof(LDKChannelManager)); return res; } + ~ChannelManager() { ChannelManager_free(self); } + ChannelManager& operator=(ChannelManager&& o) { ChannelManager_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManager)); return *this; } + LDKChannelManager* operator &() { return &self; } + LDKChannelManager* operator ->() { return &self; } + const LDKChannelManager* operator &() const { return &self; } + const LDKChannelManager* operator ->() const { return &self; } }; -class SpendableOutputDescriptor { +class ChainParameters { private: - LDKSpendableOutputDescriptor self; + LDKChainParameters self; public: - SpendableOutputDescriptor(const SpendableOutputDescriptor&) = delete; - SpendableOutputDescriptor(SpendableOutputDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SpendableOutputDescriptor)); } - SpendableOutputDescriptor(LDKSpendableOutputDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpendableOutputDescriptor)); } - operator LDKSpendableOutputDescriptor() && { LDKSpendableOutputDescriptor res = self; memset(&self, 0, sizeof(LDKSpendableOutputDescriptor)); return res; } - ~SpendableOutputDescriptor() { SpendableOutputDescriptor_free(self); } - SpendableOutputDescriptor& operator=(SpendableOutputDescriptor&& o) { SpendableOutputDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SpendableOutputDescriptor)); return *this; } - LDKSpendableOutputDescriptor* operator &() { return &self; } - LDKSpendableOutputDescriptor* operator ->() { return &self; } - const LDKSpendableOutputDescriptor* operator &() const { return &self; } - const LDKSpendableOutputDescriptor* operator ->() const { return &self; } + ChainParameters(const ChainParameters&) = delete; + ChainParameters(ChainParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChainParameters)); } + ChainParameters(LDKChainParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainParameters)); } + operator LDKChainParameters() && { LDKChainParameters res = self; memset(&self, 0, sizeof(LDKChainParameters)); return res; } + ~ChainParameters() { ChainParameters_free(self); } + ChainParameters& operator=(ChainParameters&& o) { ChainParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChainParameters)); return *this; } + LDKChainParameters* operator &() { return &self; } + LDKChainParameters* operator ->() { return &self; } + const LDKChainParameters* operator &() const { return &self; } + const LDKChainParameters* operator ->() const { return &self; } }; -class ChannelSigner { +class CounterpartyForwardingInfo { private: - LDKChannelSigner self; + LDKCounterpartyForwardingInfo self; public: - ChannelSigner(const ChannelSigner&) = delete; - ChannelSigner(ChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelSigner)); } - ChannelSigner(LDKChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelSigner)); } - operator LDKChannelSigner() && { LDKChannelSigner res = self; memset(&self, 0, sizeof(LDKChannelSigner)); return res; } - ~ChannelSigner() { ChannelSigner_free(self); } - ChannelSigner& operator=(ChannelSigner&& o) { ChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(ChannelSigner)); return *this; } - LDKChannelSigner* operator &() { return &self; } - LDKChannelSigner* operator ->() { return &self; } - const LDKChannelSigner* operator &() const { return &self; } - const LDKChannelSigner* operator ->() const { return &self; } - /** - * Gets the per-commitment point for a specific commitment number - * - * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - */ - inline LDKPublicKey get_per_commitment_point(uint64_t idx); - /** - * Gets the commitment secret for a specific commitment number as part of the revocation process - * - * An external signer implementation should error here if the commitment was already signed - * and should refuse to sign it in the future. - * - * May be called more than once for the same index. - * - * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - */ - inline LDKThirtyTwoBytes release_commitment_secret(uint64_t idx); - /** - * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. - * - * This is required in order for the signer to make sure that releasing a commitment - * secret won't leave us without a broadcastable holder transaction. - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * Note that all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. - */ - inline LDK::CResult_NoneNoneZ validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); - /** - * Returns an arbitrary identifier describing the set of keys which are provided back to you in - * some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this - * [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. - */ - inline LDKThirtyTwoBytes channel_keys_id(); - /** - * Set the counterparty static channel data, including basepoints, - * `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. - * - * This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] - * instance, LDK will call this method exactly once - either immediately after construction - * (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding - * information has been generated. - * - * channel_parameters.is_populated() MUST be true. - */ - inline void provide_channel_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters); + CounterpartyForwardingInfo(const CounterpartyForwardingInfo&) = delete; + CounterpartyForwardingInfo(CounterpartyForwardingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyForwardingInfo)); } + CounterpartyForwardingInfo(LDKCounterpartyForwardingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyForwardingInfo)); } + operator LDKCounterpartyForwardingInfo() && { LDKCounterpartyForwardingInfo res = self; memset(&self, 0, sizeof(LDKCounterpartyForwardingInfo)); return res; } + ~CounterpartyForwardingInfo() { CounterpartyForwardingInfo_free(self); } + CounterpartyForwardingInfo& operator=(CounterpartyForwardingInfo&& o) { CounterpartyForwardingInfo_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyForwardingInfo)); return *this; } + LDKCounterpartyForwardingInfo* operator &() { return &self; } + LDKCounterpartyForwardingInfo* operator ->() { return &self; } + const LDKCounterpartyForwardingInfo* operator &() const { return &self; } + const LDKCounterpartyForwardingInfo* operator ->() const { return &self; } +}; +class ChannelCounterparty { +private: + LDKChannelCounterparty self; +public: + ChannelCounterparty(const ChannelCounterparty&) = delete; + ChannelCounterparty(ChannelCounterparty&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelCounterparty)); } + ChannelCounterparty(LDKChannelCounterparty&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelCounterparty)); } + operator LDKChannelCounterparty() && { LDKChannelCounterparty res = self; memset(&self, 0, sizeof(LDKChannelCounterparty)); return res; } + ~ChannelCounterparty() { ChannelCounterparty_free(self); } + ChannelCounterparty& operator=(ChannelCounterparty&& o) { ChannelCounterparty_free(self); self = o.self; memset(&o, 0, sizeof(ChannelCounterparty)); return *this; } + LDKChannelCounterparty* operator &() { return &self; } + LDKChannelCounterparty* operator ->() { return &self; } + const LDKChannelCounterparty* operator &() const { return &self; } + const LDKChannelCounterparty* operator ->() const { return &self; } +}; +class ChannelDetails { +private: + LDKChannelDetails self; +public: + ChannelDetails(const ChannelDetails&) = delete; + ChannelDetails(ChannelDetails&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDetails)); } + ChannelDetails(LDKChannelDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDetails)); } + operator LDKChannelDetails() && { LDKChannelDetails res = self; memset(&self, 0, sizeof(LDKChannelDetails)); return res; } + ~ChannelDetails() { ChannelDetails_free(self); } + ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } + LDKChannelDetails* operator &() { return &self; } + LDKChannelDetails* operator ->() { return &self; } + const LDKChannelDetails* operator &() const { return &self; } + const LDKChannelDetails* operator ->() const { return &self; } +}; +class ChannelShutdownState { +private: + LDKChannelShutdownState self; +public: + ChannelShutdownState(const ChannelShutdownState&) = delete; + ChannelShutdownState(ChannelShutdownState&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelShutdownState)); } + ChannelShutdownState(LDKChannelShutdownState&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelShutdownState)); } + operator LDKChannelShutdownState() && { LDKChannelShutdownState res = self; memset(&self, 0, sizeof(LDKChannelShutdownState)); return res; } + ChannelShutdownState& operator=(ChannelShutdownState&& o) { self = o.self; memset(&o, 0, sizeof(ChannelShutdownState)); return *this; } + LDKChannelShutdownState* operator &() { return &self; } + LDKChannelShutdownState* operator ->() { return &self; } + const LDKChannelShutdownState* operator &() const { return &self; } + const LDKChannelShutdownState* operator ->() const { return &self; } +}; +class RecentPaymentDetails { +private: + LDKRecentPaymentDetails self; +public: + RecentPaymentDetails(const RecentPaymentDetails&) = delete; + RecentPaymentDetails(RecentPaymentDetails&& o) : self(o.self) { memset(&o, 0, sizeof(RecentPaymentDetails)); } + RecentPaymentDetails(LDKRecentPaymentDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecentPaymentDetails)); } + operator LDKRecentPaymentDetails() && { LDKRecentPaymentDetails res = self; memset(&self, 0, sizeof(LDKRecentPaymentDetails)); return res; } + ~RecentPaymentDetails() { RecentPaymentDetails_free(self); } + RecentPaymentDetails& operator=(RecentPaymentDetails&& o) { RecentPaymentDetails_free(self); self = o.self; memset(&o, 0, sizeof(RecentPaymentDetails)); return *this; } + LDKRecentPaymentDetails* operator &() { return &self; } + LDKRecentPaymentDetails* operator ->() { return &self; } + const LDKRecentPaymentDetails* operator &() const { return &self; } + const LDKRecentPaymentDetails* operator ->() const { return &self; } +}; +class PhantomRouteHints { +private: + LDKPhantomRouteHints self; +public: + PhantomRouteHints(const PhantomRouteHints&) = delete; + PhantomRouteHints(PhantomRouteHints&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomRouteHints)); } + PhantomRouteHints(LDKPhantomRouteHints&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomRouteHints)); } + operator LDKPhantomRouteHints() && { LDKPhantomRouteHints res = self; memset(&self, 0, sizeof(LDKPhantomRouteHints)); return res; } + ~PhantomRouteHints() { PhantomRouteHints_free(self); } + PhantomRouteHints& operator=(PhantomRouteHints&& o) { PhantomRouteHints_free(self); self = o.self; memset(&o, 0, sizeof(PhantomRouteHints)); return *this; } + LDKPhantomRouteHints* operator &() { return &self; } + LDKPhantomRouteHints* operator ->() { return &self; } + const LDKPhantomRouteHints* operator &() const { return &self; } + const LDKPhantomRouteHints* operator ->() const { return &self; } +}; +class ChannelManagerReadArgs { +private: + LDKChannelManagerReadArgs self; +public: + ChannelManagerReadArgs(const ChannelManagerReadArgs&) = delete; + ChannelManagerReadArgs(ChannelManagerReadArgs&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManagerReadArgs)); } + ChannelManagerReadArgs(LDKChannelManagerReadArgs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManagerReadArgs)); } + operator LDKChannelManagerReadArgs() && { LDKChannelManagerReadArgs res = self; memset(&self, 0, sizeof(LDKChannelManagerReadArgs)); return res; } + ~ChannelManagerReadArgs() { ChannelManagerReadArgs_free(self); } + ChannelManagerReadArgs& operator=(ChannelManagerReadArgs&& o) { ChannelManagerReadArgs_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManagerReadArgs)); return *this; } + LDKChannelManagerReadArgs* operator &() { return &self; } + LDKChannelManagerReadArgs* operator ->() { return &self; } + const LDKChannelManagerReadArgs* operator &() const { return &self; } + const LDKChannelManagerReadArgs* operator ->() const { return &self; } +}; +class ChannelHandshakeConfig { +private: + LDKChannelHandshakeConfig self; +public: + ChannelHandshakeConfig(const ChannelHandshakeConfig&) = delete; + ChannelHandshakeConfig(ChannelHandshakeConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeConfig)); } + ChannelHandshakeConfig(LDKChannelHandshakeConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeConfig)); } + operator LDKChannelHandshakeConfig() && { LDKChannelHandshakeConfig res = self; memset(&self, 0, sizeof(LDKChannelHandshakeConfig)); return res; } + ~ChannelHandshakeConfig() { ChannelHandshakeConfig_free(self); } + ChannelHandshakeConfig& operator=(ChannelHandshakeConfig&& o) { ChannelHandshakeConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeConfig)); return *this; } + LDKChannelHandshakeConfig* operator &() { return &self; } + LDKChannelHandshakeConfig* operator ->() { return &self; } + const LDKChannelHandshakeConfig* operator &() const { return &self; } + const LDKChannelHandshakeConfig* operator ->() const { return &self; } +}; +class ChannelHandshakeLimits { +private: + LDKChannelHandshakeLimits self; +public: + ChannelHandshakeLimits(const ChannelHandshakeLimits&) = delete; + ChannelHandshakeLimits(ChannelHandshakeLimits&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeLimits)); } + ChannelHandshakeLimits(LDKChannelHandshakeLimits&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeLimits)); } + operator LDKChannelHandshakeLimits() && { LDKChannelHandshakeLimits res = self; memset(&self, 0, sizeof(LDKChannelHandshakeLimits)); return res; } + ~ChannelHandshakeLimits() { ChannelHandshakeLimits_free(self); } + ChannelHandshakeLimits& operator=(ChannelHandshakeLimits&& o) { ChannelHandshakeLimits_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeLimits)); return *this; } + LDKChannelHandshakeLimits* operator &() { return &self; } + LDKChannelHandshakeLimits* operator ->() { return &self; } + const LDKChannelHandshakeLimits* operator &() const { return &self; } + const LDKChannelHandshakeLimits* operator ->() const { return &self; } +}; +class MaxDustHTLCExposure { +private: + LDKMaxDustHTLCExposure self; +public: + MaxDustHTLCExposure(const MaxDustHTLCExposure&) = delete; + MaxDustHTLCExposure(MaxDustHTLCExposure&& o) : self(o.self) { memset(&o, 0, sizeof(MaxDustHTLCExposure)); } + MaxDustHTLCExposure(LDKMaxDustHTLCExposure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMaxDustHTLCExposure)); } + operator LDKMaxDustHTLCExposure() && { LDKMaxDustHTLCExposure res = self; memset(&self, 0, sizeof(LDKMaxDustHTLCExposure)); return res; } + ~MaxDustHTLCExposure() { MaxDustHTLCExposure_free(self); } + MaxDustHTLCExposure& operator=(MaxDustHTLCExposure&& o) { MaxDustHTLCExposure_free(self); self = o.self; memset(&o, 0, sizeof(MaxDustHTLCExposure)); return *this; } + LDKMaxDustHTLCExposure* operator &() { return &self; } + LDKMaxDustHTLCExposure* operator ->() { return &self; } + const LDKMaxDustHTLCExposure* operator &() const { return &self; } + const LDKMaxDustHTLCExposure* operator ->() const { return &self; } +}; +class ChannelConfig { +private: + LDKChannelConfig self; +public: + ChannelConfig(const ChannelConfig&) = delete; + ChannelConfig(ChannelConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelConfig)); } + ChannelConfig(LDKChannelConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelConfig)); } + operator LDKChannelConfig() && { LDKChannelConfig res = self; memset(&self, 0, sizeof(LDKChannelConfig)); return res; } + ~ChannelConfig() { ChannelConfig_free(self); } + ChannelConfig& operator=(ChannelConfig&& o) { ChannelConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelConfig)); return *this; } + LDKChannelConfig* operator &() { return &self; } + LDKChannelConfig* operator ->() { return &self; } + const LDKChannelConfig* operator &() const { return &self; } + const LDKChannelConfig* operator ->() const { return &self; } +}; +class ChannelConfigUpdate { +private: + LDKChannelConfigUpdate self; +public: + ChannelConfigUpdate(const ChannelConfigUpdate&) = delete; + ChannelConfigUpdate(ChannelConfigUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelConfigUpdate)); } + ChannelConfigUpdate(LDKChannelConfigUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelConfigUpdate)); } + operator LDKChannelConfigUpdate() && { LDKChannelConfigUpdate res = self; memset(&self, 0, sizeof(LDKChannelConfigUpdate)); return res; } + ~ChannelConfigUpdate() { ChannelConfigUpdate_free(self); } + ChannelConfigUpdate& operator=(ChannelConfigUpdate&& o) { ChannelConfigUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelConfigUpdate)); return *this; } + LDKChannelConfigUpdate* operator &() { return &self; } + LDKChannelConfigUpdate* operator ->() { return &self; } + const LDKChannelConfigUpdate* operator &() const { return &self; } + const LDKChannelConfigUpdate* operator ->() const { return &self; } +}; +class UserConfig { +private: + LDKUserConfig self; +public: + UserConfig(const UserConfig&) = delete; + UserConfig(UserConfig&& o) : self(o.self) { memset(&o, 0, sizeof(UserConfig)); } + UserConfig(LDKUserConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUserConfig)); } + operator LDKUserConfig() && { LDKUserConfig res = self; memset(&self, 0, sizeof(LDKUserConfig)); return res; } + ~UserConfig() { UserConfig_free(self); } + UserConfig& operator=(UserConfig&& o) { UserConfig_free(self); self = o.self; memset(&o, 0, sizeof(UserConfig)); return *this; } + LDKUserConfig* operator &() { return &self; } + LDKUserConfig* operator ->() { return &self; } + const LDKUserConfig* operator &() const { return &self; } + const LDKUserConfig* operator ->() const { return &self; } +}; +class APIError { +private: + LDKAPIError self; +public: + APIError(const APIError&) = delete; + APIError(APIError&& o) : self(o.self) { memset(&o, 0, sizeof(APIError)); } + APIError(LDKAPIError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAPIError)); } + operator LDKAPIError() && { LDKAPIError res = self; memset(&self, 0, sizeof(LDKAPIError)); return res; } + ~APIError() { APIError_free(self); } + APIError& operator=(APIError&& o) { APIError_free(self); self = o.self; memset(&o, 0, sizeof(APIError)); return *this; } + LDKAPIError* operator &() { return &self; } + LDKAPIError* operator ->() { return &self; } + const LDKAPIError* operator &() const { return &self; } + const LDKAPIError* operator ->() const { return &self; } +}; +class ChannelMonitorUpdate { +private: + LDKChannelMonitorUpdate self; +public: + ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete; + ChannelMonitorUpdate(ChannelMonitorUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdate)); } + ChannelMonitorUpdate(LDKChannelMonitorUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdate)); } + operator LDKChannelMonitorUpdate() && { LDKChannelMonitorUpdate res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdate)); return res; } + ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); } + ChannelMonitorUpdate& operator=(ChannelMonitorUpdate&& o) { ChannelMonitorUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdate)); return *this; } + LDKChannelMonitorUpdate* operator &() { return &self; } + LDKChannelMonitorUpdate* operator ->() { return &self; } + const LDKChannelMonitorUpdate* operator &() const { return &self; } + const LDKChannelMonitorUpdate* operator ->() const { return &self; } +}; +class MonitorEvent { +private: + LDKMonitorEvent self; +public: + MonitorEvent(const MonitorEvent&) = delete; + MonitorEvent(MonitorEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorEvent)); } + MonitorEvent(LDKMonitorEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorEvent)); } + operator LDKMonitorEvent() && { LDKMonitorEvent res = self; memset(&self, 0, sizeof(LDKMonitorEvent)); return res; } + ~MonitorEvent() { MonitorEvent_free(self); } + MonitorEvent& operator=(MonitorEvent&& o) { MonitorEvent_free(self); self = o.self; memset(&o, 0, sizeof(MonitorEvent)); return *this; } + LDKMonitorEvent* operator &() { return &self; } + LDKMonitorEvent* operator ->() { return &self; } + const LDKMonitorEvent* operator &() const { return &self; } + const LDKMonitorEvent* operator ->() const { return &self; } +}; +class HTLCUpdate { +private: + LDKHTLCUpdate self; +public: + HTLCUpdate(const HTLCUpdate&) = delete; + HTLCUpdate(HTLCUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCUpdate)); } + HTLCUpdate(LDKHTLCUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCUpdate)); } + operator LDKHTLCUpdate() && { LDKHTLCUpdate res = self; memset(&self, 0, sizeof(LDKHTLCUpdate)); return res; } + ~HTLCUpdate() { HTLCUpdate_free(self); } + HTLCUpdate& operator=(HTLCUpdate&& o) { HTLCUpdate_free(self); self = o.self; memset(&o, 0, sizeof(HTLCUpdate)); return *this; } + LDKHTLCUpdate* operator &() { return &self; } + LDKHTLCUpdate* operator ->() { return &self; } + const LDKHTLCUpdate* operator &() const { return &self; } + const LDKHTLCUpdate* operator ->() const { return &self; } }; -class EcdsaChannelSigner { +class Balance { private: - LDKEcdsaChannelSigner self; + LDKBalance self; public: - EcdsaChannelSigner(const EcdsaChannelSigner&) = delete; - EcdsaChannelSigner(EcdsaChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(EcdsaChannelSigner)); } - EcdsaChannelSigner(LDKEcdsaChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEcdsaChannelSigner)); } - operator LDKEcdsaChannelSigner() && { LDKEcdsaChannelSigner res = self; memset(&self, 0, sizeof(LDKEcdsaChannelSigner)); return res; } - ~EcdsaChannelSigner() { EcdsaChannelSigner_free(self); } - EcdsaChannelSigner& operator=(EcdsaChannelSigner&& o) { EcdsaChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(EcdsaChannelSigner)); return *this; } - LDKEcdsaChannelSigner* operator &() { return &self; } - LDKEcdsaChannelSigner* operator ->() { return &self; } - const LDKEcdsaChannelSigner* operator &() const { return &self; } - const LDKEcdsaChannelSigner* operator ->() const { return &self; } - /** - * Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - * - * Note that if signing fails or is rejected, the channel will be force-closed. - * - * Policy checks should be implemented in this function, including checking the amount - * sent to us and checking the HTLCs. - * - * The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - * A validating signer should ensure that an HTLC output is removed only when the matching - * preimage is provided, or when the value to holder is restored. - * - * Note that all the relevant preimages will be provided, but there may also be additional - * irrelevant or duplicate preimages. - */ - inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); + Balance(const Balance&) = delete; + Balance(Balance&& o) : self(o.self) { memset(&o, 0, sizeof(Balance)); } + Balance(LDKBalance&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBalance)); } + operator LDKBalance() && { LDKBalance res = self; memset(&self, 0, sizeof(LDKBalance)); return res; } + ~Balance() { Balance_free(self); } + Balance& operator=(Balance&& o) { Balance_free(self); self = o.self; memset(&o, 0, sizeof(Balance)); return *this; } + LDKBalance* operator &() { return &self; } + LDKBalance* operator ->() { return &self; } + const LDKBalance* operator &() const { return &self; } + const LDKBalance* operator ->() const { return &self; } +}; +class ChannelMonitor { +private: + LDKChannelMonitor self; +public: + ChannelMonitor(const ChannelMonitor&) = delete; + ChannelMonitor(ChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitor)); } + ChannelMonitor(LDKChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitor)); } + operator LDKChannelMonitor() && { LDKChannelMonitor res = self; memset(&self, 0, sizeof(LDKChannelMonitor)); return res; } + ~ChannelMonitor() { ChannelMonitor_free(self); } + ChannelMonitor& operator=(ChannelMonitor&& o) { ChannelMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitor)); return *this; } + LDKChannelMonitor* operator &() { return &self; } + LDKChannelMonitor* operator ->() { return &self; } + const LDKChannelMonitor* operator &() const { return &self; } + const LDKChannelMonitor* operator ->() const { return &self; } +}; +class ExpandedKey { +private: + LDKExpandedKey self; +public: + ExpandedKey(const ExpandedKey&) = delete; + ExpandedKey(ExpandedKey&& o) : self(o.self) { memset(&o, 0, sizeof(ExpandedKey)); } + ExpandedKey(LDKExpandedKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpandedKey)); } + operator LDKExpandedKey() && { LDKExpandedKey res = self; memset(&self, 0, sizeof(LDKExpandedKey)); return res; } + ~ExpandedKey() { ExpandedKey_free(self); } + ExpandedKey& operator=(ExpandedKey&& o) { ExpandedKey_free(self); self = o.self; memset(&o, 0, sizeof(ExpandedKey)); return *this; } + LDKExpandedKey* operator &() { return &self; } + LDKExpandedKey* operator ->() { return &self; } + const LDKExpandedKey* operator &() const { return &self; } + const LDKExpandedKey* operator ->() const { return &self; } +}; +class CustomMessageHandler { +private: + LDKCustomMessageHandler self; +public: + CustomMessageHandler(const CustomMessageHandler&) = delete; + CustomMessageHandler(CustomMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageHandler)); } + CustomMessageHandler(LDKCustomMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageHandler)); } + operator LDKCustomMessageHandler() && { LDKCustomMessageHandler res = self; memset(&self, 0, sizeof(LDKCustomMessageHandler)); return res; } + ~CustomMessageHandler() { CustomMessageHandler_free(self); } + CustomMessageHandler& operator=(CustomMessageHandler&& o) { CustomMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageHandler)); return *this; } + LDKCustomMessageHandler* operator &() { return &self; } + LDKCustomMessageHandler* operator ->() { return &self; } + const LDKCustomMessageHandler* operator &() const { return &self; } + const LDKCustomMessageHandler* operator ->() const { return &self; } /** - * Validate the counterparty's revocation. - * - * This is required in order for the signer to make sure that the state has moved - * forward and it is safe to sign the next counterparty commitment. + * Handles the given message sent from `sender_node_id`, possibly producing messages for + * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] + * to send. */ - inline LDK::CResult_NoneNoneZ validate_counterparty_revocation(uint64_t idx, const uint8_t (*secret)[32]); + inline LDK::CResult_NoneLightningErrorZ handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id); /** - * Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. - * - * This will be called - * - with a non-revoked `commitment_tx`. - * - with the latest `commitment_tx` when we initiate a force-close. - * - with the previous `commitment_tx`, just to get claiming HTLC - * signatures, if we are reacting to a [`ChannelMonitor`] - * [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) - * that decided to broadcast before it had been updated to the latest `commitment_tx`. - * - * This may be called multiple times for the same transaction. - * - * An external signer implementation should check that the commitment has not been revoked. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * Returns the list of pending messages that were generated by the handler, clearing the list + * in the process. Each message is paired with the node id of the intended recipient. If no + * connection to the node exists, then the message is simply not sent. */ - inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); + inline LDK::CVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg(); /** - * Create a signature for the given input in a transaction spending an HTLC transaction output - * or a commitment transaction `to_local` output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * Amount is value of the output spent by this input, committed to in the BIP 143 signature. + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. * - * `per_commitment_key` is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do - * so). + * [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement */ - inline LDK::CResult_SignatureNoneZ sign_justice_revoked_output(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); + inline LDK::NodeFeatures provided_node_features(); /** - * Create a signature for the given input in a transaction spending a commitment transaction - * HTLC output when our counterparty broadcasts an old state. - * - * A justice transaction may claim multiple outputs at the same time if timelocks are - * similar, but only a signature for the input at index `input` should be signed for here. - * It may be called multiple times for same output(s) if a fee-bump is needed with regards - * to an upcoming timelock expiration. - * - * `amount` is the value of the output spent by this input, committed to in the BIP 143 - * signature. - * - * `per_commitment_key` is revocation secret which was provided by our counterparty when they - * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - * not allow the spending of any funds by itself (you need our holder revocation_secret to do - * so). + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. * - * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script - * (which is committed to in the BIP 143 signatures). + * [`Init`]: crate::ln::msgs::Init */ - inline LDK::CResult_SignatureNoneZ sign_justice_revoked_htlc(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); +}; +class IgnoringMessageHandler { +private: + LDKIgnoringMessageHandler self; +public: + IgnoringMessageHandler(const IgnoringMessageHandler&) = delete; + IgnoringMessageHandler(IgnoringMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(IgnoringMessageHandler)); } + IgnoringMessageHandler(LDKIgnoringMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKIgnoringMessageHandler)); } + operator LDKIgnoringMessageHandler() && { LDKIgnoringMessageHandler res = self; memset(&self, 0, sizeof(LDKIgnoringMessageHandler)); return res; } + ~IgnoringMessageHandler() { IgnoringMessageHandler_free(self); } + IgnoringMessageHandler& operator=(IgnoringMessageHandler&& o) { IgnoringMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(IgnoringMessageHandler)); return *this; } + LDKIgnoringMessageHandler* operator &() { return &self; } + LDKIgnoringMessageHandler* operator ->() { return &self; } + const LDKIgnoringMessageHandler* operator &() const { return &self; } + const LDKIgnoringMessageHandler* operator ->() const { return &self; } +}; +class ErroringMessageHandler { +private: + LDKErroringMessageHandler self; +public: + ErroringMessageHandler(const ErroringMessageHandler&) = delete; + ErroringMessageHandler(ErroringMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(ErroringMessageHandler)); } + ErroringMessageHandler(LDKErroringMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErroringMessageHandler)); } + operator LDKErroringMessageHandler() && { LDKErroringMessageHandler res = self; memset(&self, 0, sizeof(LDKErroringMessageHandler)); return res; } + ~ErroringMessageHandler() { ErroringMessageHandler_free(self); } + ErroringMessageHandler& operator=(ErroringMessageHandler&& o) { ErroringMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ErroringMessageHandler)); return *this; } + LDKErroringMessageHandler* operator &() { return &self; } + LDKErroringMessageHandler* operator ->() { return &self; } + const LDKErroringMessageHandler* operator &() const { return &self; } + const LDKErroringMessageHandler* operator ->() const { return &self; } +}; +class MessageHandler { +private: + LDKMessageHandler self; +public: + MessageHandler(const MessageHandler&) = delete; + MessageHandler(MessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(MessageHandler)); } + MessageHandler(LDKMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageHandler)); } + operator LDKMessageHandler() && { LDKMessageHandler res = self; memset(&self, 0, sizeof(LDKMessageHandler)); return res; } + ~MessageHandler() { MessageHandler_free(self); } + MessageHandler& operator=(MessageHandler&& o) { MessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(MessageHandler)); return *this; } + LDKMessageHandler* operator &() { return &self; } + LDKMessageHandler* operator ->() { return &self; } + const LDKMessageHandler* operator &() const { return &self; } + const LDKMessageHandler* operator ->() const { return &self; } +}; +class SocketDescriptor { +private: + LDKSocketDescriptor self; +public: + SocketDescriptor(const SocketDescriptor&) = delete; + SocketDescriptor(SocketDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SocketDescriptor)); } + SocketDescriptor(LDKSocketDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSocketDescriptor)); } + operator LDKSocketDescriptor() && { LDKSocketDescriptor res = self; memset(&self, 0, sizeof(LDKSocketDescriptor)); return res; } + ~SocketDescriptor() { SocketDescriptor_free(self); } + SocketDescriptor& operator=(SocketDescriptor&& o) { SocketDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SocketDescriptor)); return *this; } + LDKSocketDescriptor* operator &() { return &self; } + LDKSocketDescriptor* operator ->() { return &self; } + const LDKSocketDescriptor* operator &() const { return &self; } + const LDKSocketDescriptor* operator ->() const { return &self; } /** - * Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - * transaction, either offered or received. - * - * Such a transaction may claim multiples offered outputs at same time if we know the - * preimage for each when we create it, but only the input at index `input` should be - * signed for here. It may be called multiple times for same output(s) if a fee-bump is - * needed with regards to an upcoming timelock expiration. + * Attempts to send some data from the given slice to the peer. * - * `witness_script` is either an offered or received script as defined in BOLT3 for HTLC - * outputs. + * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. + * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be + * called and further write attempts may occur until that time. * - * `amount` is value of the output spent by this input, committed to in the BIP 143 signature. + * If the returned size is smaller than `data.len()`, a + * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be + * written. Additionally, until a `send_data` event completes fully, no further + * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to + * prevent denial-of-service issues, you should not read or buffer any data from the socket + * until then. * - * `per_commitment_point` is the dynamic point corresponding to the channel state - * detected onchain. It has been generated by our counterparty and is used to derive - * channel state keys, which are then included in the witness script and committed to in the - * BIP 143 signature. + * If a [`PeerManager::read_event`] call on this descriptor had previously returned true + * (indicating that read events should be paused to prevent DoS in the send buffer), + * `resume_read` may be set indicating that read events on this descriptor should resume. A + * `resume_read` of false carries no meaning, and should not cause any action. */ - inline LDK::CResult_SignatureNoneZ sign_counterparty_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); + inline uintptr_t send_data(struct LDKu8slice data, bool resume_read); /** - * Create a signature for a (proposed) closing transaction. + * Disconnect the socket pointed to by this SocketDescriptor. * - * Note that, due to rounding, there may be one "missing" satoshi, and either party may have - * chosen to forgo their output as dust. - */ - inline LDK::CResult_SignatureNoneZ sign_closing_transaction(const struct LDKClosingTransaction *NONNULL_PTR closing_tx); - /** - * Computes the signature for a commitment transaction's anchor output used as an - * input within `anchor_tx`, which spends the commitment transaction, at index `input`. + * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this + * call (doing so is a noop). */ - inline LDK::CResult_SignatureNoneZ sign_holder_anchor_input(struct LDKTransaction anchor_tx, uintptr_t input); + inline void disconnect_socket(); + /** Checks if two objects are equal given this object's this_arg pointer and another object. */ + inline bool eq(const struct LDKSocketDescriptor *NONNULL_PTR other_arg); /** - * Signs a channel announcement message with our funding key proving it comes from one of the - * channel participants. - * - * Channel announcements also require a signature from each node's network key. Our node - * signature is computed through [`NodeSigner::sign_gossip_message`]. - * - * Note that if this fails or is rejected, the channel will not be publicly announced and - * our counterparty may (though likely will not) close the channel on us for violating the - * protocol. + * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. + * This is used, for example, for inclusion of this object in a hash map. */ - inline LDK::CResult_SignatureNoneZ sign_channel_announcement_with_funding_key(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + inline uint64_t hash(); }; -class WriteableEcdsaChannelSigner { +class PeerHandleError { private: - LDKWriteableEcdsaChannelSigner self; + LDKPeerHandleError self; public: - WriteableEcdsaChannelSigner(const WriteableEcdsaChannelSigner&) = delete; - WriteableEcdsaChannelSigner(WriteableEcdsaChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); } - WriteableEcdsaChannelSigner(LDKWriteableEcdsaChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); } - operator LDKWriteableEcdsaChannelSigner() && { LDKWriteableEcdsaChannelSigner res = self; memset(&self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); return res; } - ~WriteableEcdsaChannelSigner() { WriteableEcdsaChannelSigner_free(self); } - WriteableEcdsaChannelSigner& operator=(WriteableEcdsaChannelSigner&& o) { WriteableEcdsaChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); return *this; } - LDKWriteableEcdsaChannelSigner* operator &() { return &self; } - LDKWriteableEcdsaChannelSigner* operator ->() { return &self; } - const LDKWriteableEcdsaChannelSigner* operator &() const { return &self; } - const LDKWriteableEcdsaChannelSigner* operator ->() const { return &self; } + PeerHandleError(const PeerHandleError&) = delete; + PeerHandleError(PeerHandleError&& o) : self(o.self) { memset(&o, 0, sizeof(PeerHandleError)); } + PeerHandleError(LDKPeerHandleError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerHandleError)); } + operator LDKPeerHandleError() && { LDKPeerHandleError res = self; memset(&self, 0, sizeof(LDKPeerHandleError)); return res; } + ~PeerHandleError() { PeerHandleError_free(self); } + PeerHandleError& operator=(PeerHandleError&& o) { PeerHandleError_free(self); self = o.self; memset(&o, 0, sizeof(PeerHandleError)); return *this; } + LDKPeerHandleError* operator &() { return &self; } + LDKPeerHandleError* operator ->() { return &self; } + const LDKPeerHandleError* operator &() const { return &self; } + const LDKPeerHandleError* operator ->() const { return &self; } }; -class Recipient { +class PeerManager { private: - LDKRecipient self; + LDKPeerManager self; public: - Recipient(const Recipient&) = delete; - Recipient(Recipient&& o) : self(o.self) { memset(&o, 0, sizeof(Recipient)); } - Recipient(LDKRecipient&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecipient)); } - operator LDKRecipient() && { LDKRecipient res = self; memset(&self, 0, sizeof(LDKRecipient)); return res; } - Recipient& operator=(Recipient&& o) { self = o.self; memset(&o, 0, sizeof(Recipient)); return *this; } - LDKRecipient* operator &() { return &self; } - LDKRecipient* operator ->() { return &self; } - const LDKRecipient* operator &() const { return &self; } - const LDKRecipient* operator ->() const { return &self; } + PeerManager(const PeerManager&) = delete; + PeerManager(PeerManager&& o) : self(o.self) { memset(&o, 0, sizeof(PeerManager)); } + PeerManager(LDKPeerManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerManager)); } + operator LDKPeerManager() && { LDKPeerManager res = self; memset(&self, 0, sizeof(LDKPeerManager)); return res; } + ~PeerManager() { PeerManager_free(self); } + PeerManager& operator=(PeerManager&& o) { PeerManager_free(self); self = o.self; memset(&o, 0, sizeof(PeerManager)); return *this; } + LDKPeerManager* operator &() { return &self; } + LDKPeerManager* operator ->() { return &self; } + const LDKPeerManager* operator &() const { return &self; } + const LDKPeerManager* operator ->() const { return &self; } }; -class EntropySource { +class RapidGossipSync { private: - LDKEntropySource self; + LDKRapidGossipSync self; public: - EntropySource(const EntropySource&) = delete; - EntropySource(EntropySource&& o) : self(o.self) { memset(&o, 0, sizeof(EntropySource)); } - EntropySource(LDKEntropySource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEntropySource)); } - operator LDKEntropySource() && { LDKEntropySource res = self; memset(&self, 0, sizeof(LDKEntropySource)); return res; } - ~EntropySource() { EntropySource_free(self); } - EntropySource& operator=(EntropySource&& o) { EntropySource_free(self); self = o.self; memset(&o, 0, sizeof(EntropySource)); return *this; } - LDKEntropySource* operator &() { return &self; } - LDKEntropySource* operator ->() { return &self; } - const LDKEntropySource* operator &() const { return &self; } - const LDKEntropySource* operator ->() const { return &self; } - /** - * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a - * different value each time it is called. - */ - inline LDKThirtyTwoBytes get_secure_random_bytes(); + RapidGossipSync(const RapidGossipSync&) = delete; + RapidGossipSync(RapidGossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(RapidGossipSync)); } + RapidGossipSync(LDKRapidGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRapidGossipSync)); } + operator LDKRapidGossipSync() && { LDKRapidGossipSync res = self; memset(&self, 0, sizeof(LDKRapidGossipSync)); return res; } + ~RapidGossipSync() { RapidGossipSync_free(self); } + RapidGossipSync& operator=(RapidGossipSync&& o) { RapidGossipSync_free(self); self = o.self; memset(&o, 0, sizeof(RapidGossipSync)); return *this; } + LDKRapidGossipSync* operator &() { return &self; } + LDKRapidGossipSync* operator ->() { return &self; } + const LDKRapidGossipSync* operator &() const { return &self; } + const LDKRapidGossipSync* operator ->() const { return &self; } }; -class NodeSigner { +class Persister { private: - LDKNodeSigner self; + LDKPersister self; public: - NodeSigner(const NodeSigner&) = delete; - NodeSigner(NodeSigner&& o) : self(o.self) { memset(&o, 0, sizeof(NodeSigner)); } - NodeSigner(LDKNodeSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeSigner)); } - operator LDKNodeSigner() && { LDKNodeSigner res = self; memset(&self, 0, sizeof(LDKNodeSigner)); return res; } - ~NodeSigner() { NodeSigner_free(self); } - NodeSigner& operator=(NodeSigner&& o) { NodeSigner_free(self); self = o.self; memset(&o, 0, sizeof(NodeSigner)); return *this; } - LDKNodeSigner* operator &() { return &self; } - LDKNodeSigner* operator ->() { return &self; } - const LDKNodeSigner* operator &() const { return &self; } - const LDKNodeSigner* operator ->() const { return &self; } - /** - * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. - * - * If the implementor of this trait supports [phantom node payments], then every node that is - * intended to be included in the phantom invoice route hints must return the same value from - * this method. - * - * This method must return the same value each time it is called. - * - * [phantom node payments]: PhantomKeysManager - */ - inline LDKThirtyTwoBytes get_inbound_payment_key_material(); - /** - * Get node id based on the provided [`Recipient`]. - * - * This method must return the same value each time it is called with a given [`Recipient`] - * parameter. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. - */ - inline LDK::CResult_PublicKeyNoneZ get_node_id(enum LDKRecipient recipient); + Persister(const Persister&) = delete; + Persister(Persister&& o) : self(o.self) { memset(&o, 0, sizeof(Persister)); } + Persister(LDKPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersister)); } + operator LDKPersister() && { LDKPersister res = self; memset(&self, 0, sizeof(LDKPersister)); return res; } + ~Persister() { Persister_free(self); } + Persister& operator=(Persister&& o) { Persister_free(self); self = o.self; memset(&o, 0, sizeof(Persister)); return *this; } + LDKPersister* operator &() { return &self; } + LDKPersister* operator ->() { return &self; } + const LDKPersister* operator &() const { return &self; } + const LDKPersister* operator ->() const { return &self; } /** - * Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if - * one is provided. Note that this tweak can be applied to `other_key` instead of our node - * secret, though this is less efficient. - * - * Note that if this fails while attempting to forward an HTLC, LDK will panic. The error - * should be resolved to allow LDK to resume forwarding HTLCs. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. + * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. */ - inline LDK::CResult_SharedSecretNoneZ ecdh(enum LDKRecipient recipient, struct LDKPublicKey other_key, struct LDKCOption_ScalarZ tweak); + inline LDK::CResult_NoneErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager); /** - * Sign an invoice. - * - * By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of - * this trait to parse the invoice and make sure they're signing what they expect, rather than - * blindly signing the hash. - * - * The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. - * - * The secret key used to sign the invoice is dependent on the [`Recipient`]. - * - * Errors if the [`Recipient`] variant is not supported by the implementation. + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. */ - inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); + inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** - * Sign a gossip message. - * - * Note that if this fails, LDK may panic and the message will not be broadcast to the network - * or a possible channel counterparty. If LDK panics, the error should be resolved to allow the - * message to be broadcast, as otherwise it may prevent one from receiving funds over the - * corresponding channel. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - inline LDK::CResult_SignatureNoneZ sign_gossip_message(struct LDKUnsignedGossipMessage msg); + inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer); +}; +class UnsignedInvoiceRequest { +private: + LDKUnsignedInvoiceRequest self; +public: + UnsignedInvoiceRequest(const UnsignedInvoiceRequest&) = delete; + UnsignedInvoiceRequest(UnsignedInvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedInvoiceRequest)); } + UnsignedInvoiceRequest(LDKUnsignedInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedInvoiceRequest)); } + operator LDKUnsignedInvoiceRequest() && { LDKUnsignedInvoiceRequest res = self; memset(&self, 0, sizeof(LDKUnsignedInvoiceRequest)); return res; } + ~UnsignedInvoiceRequest() { UnsignedInvoiceRequest_free(self); } + UnsignedInvoiceRequest& operator=(UnsignedInvoiceRequest&& o) { UnsignedInvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedInvoiceRequest)); return *this; } + LDKUnsignedInvoiceRequest* operator &() { return &self; } + LDKUnsignedInvoiceRequest* operator ->() { return &self; } + const LDKUnsignedInvoiceRequest* operator &() const { return &self; } + const LDKUnsignedInvoiceRequest* operator ->() const { return &self; } +}; +class InvoiceRequest { +private: + LDKInvoiceRequest self; +public: + InvoiceRequest(const InvoiceRequest&) = delete; + InvoiceRequest(InvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequest)); } + InvoiceRequest(LDKInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequest)); } + operator LDKInvoiceRequest() && { LDKInvoiceRequest res = self; memset(&self, 0, sizeof(LDKInvoiceRequest)); return res; } + ~InvoiceRequest() { InvoiceRequest_free(self); } + InvoiceRequest& operator=(InvoiceRequest&& o) { InvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequest)); return *this; } + LDKInvoiceRequest* operator &() { return &self; } + LDKInvoiceRequest* operator ->() { return &self; } + const LDKInvoiceRequest* operator &() const { return &self; } + const LDKInvoiceRequest* operator ->() const { return &self; } +}; +class DecodeError { +private: + LDKDecodeError self; +public: + DecodeError(const DecodeError&) = delete; + DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); } + DecodeError(LDKDecodeError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDecodeError)); } + operator LDKDecodeError() && { LDKDecodeError res = self; memset(&self, 0, sizeof(LDKDecodeError)); return res; } + ~DecodeError() { DecodeError_free(self); } + DecodeError& operator=(DecodeError&& o) { DecodeError_free(self); self = o.self; memset(&o, 0, sizeof(DecodeError)); return *this; } + LDKDecodeError* operator &() { return &self; } + LDKDecodeError* operator ->() { return &self; } + const LDKDecodeError* operator &() const { return &self; } + const LDKDecodeError* operator ->() const { return &self; } +}; +class Init { +private: + LDKInit self; +public: + Init(const Init&) = delete; + Init(Init&& o) : self(o.self) { memset(&o, 0, sizeof(Init)); } + Init(LDKInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInit)); } + operator LDKInit() && { LDKInit res = self; memset(&self, 0, sizeof(LDKInit)); return res; } + ~Init() { Init_free(self); } + Init& operator=(Init&& o) { Init_free(self); self = o.self; memset(&o, 0, sizeof(Init)); return *this; } + LDKInit* operator &() { return &self; } + LDKInit* operator ->() { return &self; } + const LDKInit* operator &() const { return &self; } + const LDKInit* operator ->() const { return &self; } +}; +class ErrorMessage { +private: + LDKErrorMessage self; +public: + ErrorMessage(const ErrorMessage&) = delete; + ErrorMessage(ErrorMessage&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorMessage)); } + ErrorMessage(LDKErrorMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorMessage)); } + operator LDKErrorMessage() && { LDKErrorMessage res = self; memset(&self, 0, sizeof(LDKErrorMessage)); return res; } + ~ErrorMessage() { ErrorMessage_free(self); } + ErrorMessage& operator=(ErrorMessage&& o) { ErrorMessage_free(self); self = o.self; memset(&o, 0, sizeof(ErrorMessage)); return *this; } + LDKErrorMessage* operator &() { return &self; } + LDKErrorMessage* operator ->() { return &self; } + const LDKErrorMessage* operator &() const { return &self; } + const LDKErrorMessage* operator ->() const { return &self; } +}; +class WarningMessage { +private: + LDKWarningMessage self; +public: + WarningMessage(const WarningMessage&) = delete; + WarningMessage(WarningMessage&& o) : self(o.self) { memset(&o, 0, sizeof(WarningMessage)); } + WarningMessage(LDKWarningMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWarningMessage)); } + operator LDKWarningMessage() && { LDKWarningMessage res = self; memset(&self, 0, sizeof(LDKWarningMessage)); return res; } + ~WarningMessage() { WarningMessage_free(self); } + WarningMessage& operator=(WarningMessage&& o) { WarningMessage_free(self); self = o.self; memset(&o, 0, sizeof(WarningMessage)); return *this; } + LDKWarningMessage* operator &() { return &self; } + LDKWarningMessage* operator ->() { return &self; } + const LDKWarningMessage* operator &() const { return &self; } + const LDKWarningMessage* operator ->() const { return &self; } }; -class SignerProvider { +class Ping { private: - LDKSignerProvider self; + LDKPing self; public: - SignerProvider(const SignerProvider&) = delete; - SignerProvider(SignerProvider&& o) : self(o.self) { memset(&o, 0, sizeof(SignerProvider)); } - SignerProvider(LDKSignerProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignerProvider)); } - operator LDKSignerProvider() && { LDKSignerProvider res = self; memset(&self, 0, sizeof(LDKSignerProvider)); return res; } - ~SignerProvider() { SignerProvider_free(self); } - SignerProvider& operator=(SignerProvider&& o) { SignerProvider_free(self); self = o.self; memset(&o, 0, sizeof(SignerProvider)); return *this; } - LDKSignerProvider* operator &() { return &self; } - LDKSignerProvider* operator ->() { return &self; } - const LDKSignerProvider* operator &() const { return &self; } - const LDKSignerProvider* operator ->() const { return &self; } - /** - * Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through - * [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow - * implementations of [`SignerProvider`] to maintain a mapping between itself and the generated - * `channel_keys_id`. - * - * This method must return a different value each time it is called. - */ - inline LDKThirtyTwoBytes generate_channel_keys_id(bool inbound, uint64_t channel_value_satoshis, struct LDKU128 user_channel_id); - /** - * Derives the private key material backing a `Signer`. - * - * To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through - * [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be - * re-derived from its `channel_keys_id`, which can be obtained through its trait method - * [`ChannelSigner::channel_keys_id`]. - */ - inline LDK::WriteableEcdsaChannelSigner derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); - /** - * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. - * This is only called during deserialization of other objects which contain - * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). - * The bytes are exactly those which `::write()` writes, and - * contain no versioning scheme. You may wish to include your own version prefix and ensure - * you've read all of the provided bytes to ensure no corruption occurred. - * - * This method is slowly being phased out -- it will only be called when reading objects - * written by LDK versions prior to 0.0.113. - * - * [`Signer`]: Self::Signer - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - */ - inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); - /** - * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - inline LDK::CVec_u8Z get_destination_script(); - /** - * Get a script pubkey which we will send funds to when closing a channel. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. - */ - inline LDK::ShutdownScript get_shutdown_scriptpubkey(); + Ping(const Ping&) = delete; + Ping(Ping&& o) : self(o.self) { memset(&o, 0, sizeof(Ping)); } + Ping(LDKPing&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPing)); } + operator LDKPing() && { LDKPing res = self; memset(&self, 0, sizeof(LDKPing)); return res; } + ~Ping() { Ping_free(self); } + Ping& operator=(Ping&& o) { Ping_free(self); self = o.self; memset(&o, 0, sizeof(Ping)); return *this; } + LDKPing* operator &() { return &self; } + LDKPing* operator ->() { return &self; } + const LDKPing* operator &() const { return &self; } + const LDKPing* operator ->() const { return &self; } }; -class InMemorySigner { +class Pong { private: - LDKInMemorySigner self; + LDKPong self; public: - InMemorySigner(const InMemorySigner&) = delete; - InMemorySigner(InMemorySigner&& o) : self(o.self) { memset(&o, 0, sizeof(InMemorySigner)); } - InMemorySigner(LDKInMemorySigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInMemorySigner)); } - operator LDKInMemorySigner() && { LDKInMemorySigner res = self; memset(&self, 0, sizeof(LDKInMemorySigner)); return res; } - ~InMemorySigner() { InMemorySigner_free(self); } - InMemorySigner& operator=(InMemorySigner&& o) { InMemorySigner_free(self); self = o.self; memset(&o, 0, sizeof(InMemorySigner)); return *this; } - LDKInMemorySigner* operator &() { return &self; } - LDKInMemorySigner* operator ->() { return &self; } - const LDKInMemorySigner* operator &() const { return &self; } - const LDKInMemorySigner* operator ->() const { return &self; } + Pong(const Pong&) = delete; + Pong(Pong&& o) : self(o.self) { memset(&o, 0, sizeof(Pong)); } + Pong(LDKPong&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPong)); } + operator LDKPong() && { LDKPong res = self; memset(&self, 0, sizeof(LDKPong)); return res; } + ~Pong() { Pong_free(self); } + Pong& operator=(Pong&& o) { Pong_free(self); self = o.self; memset(&o, 0, sizeof(Pong)); return *this; } + LDKPong* operator &() { return &self; } + LDKPong* operator ->() { return &self; } + const LDKPong* operator &() const { return &self; } + const LDKPong* operator ->() const { return &self; } }; -class KeysManager { +class OpenChannel { private: - LDKKeysManager self; + LDKOpenChannel self; public: - KeysManager(const KeysManager&) = delete; - KeysManager(KeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(KeysManager)); } - KeysManager(LDKKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKKeysManager)); } - operator LDKKeysManager() && { LDKKeysManager res = self; memset(&self, 0, sizeof(LDKKeysManager)); return res; } - ~KeysManager() { KeysManager_free(self); } - KeysManager& operator=(KeysManager&& o) { KeysManager_free(self); self = o.self; memset(&o, 0, sizeof(KeysManager)); return *this; } - LDKKeysManager* operator &() { return &self; } - LDKKeysManager* operator ->() { return &self; } - const LDKKeysManager* operator &() const { return &self; } - const LDKKeysManager* operator ->() const { return &self; } + OpenChannel(const OpenChannel&) = delete; + OpenChannel(OpenChannel&& o) : self(o.self) { memset(&o, 0, sizeof(OpenChannel)); } + OpenChannel(LDKOpenChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOpenChannel)); } + operator LDKOpenChannel() && { LDKOpenChannel res = self; memset(&self, 0, sizeof(LDKOpenChannel)); return res; } + ~OpenChannel() { OpenChannel_free(self); } + OpenChannel& operator=(OpenChannel&& o) { OpenChannel_free(self); self = o.self; memset(&o, 0, sizeof(OpenChannel)); return *this; } + LDKOpenChannel* operator &() { return &self; } + LDKOpenChannel* operator ->() { return &self; } + const LDKOpenChannel* operator &() const { return &self; } + const LDKOpenChannel* operator ->() const { return &self; } }; -class PhantomKeysManager { +class OpenChannelV2 { private: - LDKPhantomKeysManager self; + LDKOpenChannelV2 self; public: - PhantomKeysManager(const PhantomKeysManager&) = delete; - PhantomKeysManager(PhantomKeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomKeysManager)); } - PhantomKeysManager(LDKPhantomKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomKeysManager)); } - operator LDKPhantomKeysManager() && { LDKPhantomKeysManager res = self; memset(&self, 0, sizeof(LDKPhantomKeysManager)); return res; } - ~PhantomKeysManager() { PhantomKeysManager_free(self); } - PhantomKeysManager& operator=(PhantomKeysManager&& o) { PhantomKeysManager_free(self); self = o.self; memset(&o, 0, sizeof(PhantomKeysManager)); return *this; } - LDKPhantomKeysManager* operator &() { return &self; } - LDKPhantomKeysManager* operator ->() { return &self; } - const LDKPhantomKeysManager* operator &() const { return &self; } - const LDKPhantomKeysManager* operator ->() const { return &self; } + OpenChannelV2(const OpenChannelV2&) = delete; + OpenChannelV2(OpenChannelV2&& o) : self(o.self) { memset(&o, 0, sizeof(OpenChannelV2)); } + OpenChannelV2(LDKOpenChannelV2&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOpenChannelV2)); } + operator LDKOpenChannelV2() && { LDKOpenChannelV2 res = self; memset(&self, 0, sizeof(LDKOpenChannelV2)); return res; } + ~OpenChannelV2() { OpenChannelV2_free(self); } + OpenChannelV2& operator=(OpenChannelV2&& o) { OpenChannelV2_free(self); self = o.self; memset(&o, 0, sizeof(OpenChannelV2)); return *this; } + LDKOpenChannelV2* operator &() { return &self; } + LDKOpenChannelV2* operator ->() { return &self; } + const LDKOpenChannelV2* operator &() const { return &self; } + const LDKOpenChannelV2* operator ->() const { return &self; } }; -class FilesystemPersister { +class AcceptChannel { private: - LDKFilesystemPersister self; + LDKAcceptChannel self; public: - FilesystemPersister(const FilesystemPersister&) = delete; - FilesystemPersister(FilesystemPersister&& o) : self(o.self) { memset(&o, 0, sizeof(FilesystemPersister)); } - FilesystemPersister(LDKFilesystemPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilesystemPersister)); } - operator LDKFilesystemPersister() && { LDKFilesystemPersister res = self; memset(&self, 0, sizeof(LDKFilesystemPersister)); return res; } - ~FilesystemPersister() { FilesystemPersister_free(self); } - FilesystemPersister& operator=(FilesystemPersister&& o) { FilesystemPersister_free(self); self = o.self; memset(&o, 0, sizeof(FilesystemPersister)); return *this; } - LDKFilesystemPersister* operator &() { return &self; } - LDKFilesystemPersister* operator ->() { return &self; } - const LDKFilesystemPersister* operator &() const { return &self; } - const LDKFilesystemPersister* operator ->() const { return &self; } + AcceptChannel(const AcceptChannel&) = delete; + AcceptChannel(AcceptChannel&& o) : self(o.self) { memset(&o, 0, sizeof(AcceptChannel)); } + AcceptChannel(LDKAcceptChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAcceptChannel)); } + operator LDKAcceptChannel() && { LDKAcceptChannel res = self; memset(&self, 0, sizeof(LDKAcceptChannel)); return res; } + ~AcceptChannel() { AcceptChannel_free(self); } + AcceptChannel& operator=(AcceptChannel&& o) { AcceptChannel_free(self); self = o.self; memset(&o, 0, sizeof(AcceptChannel)); return *this; } + LDKAcceptChannel* operator &() { return &self; } + LDKAcceptChannel* operator ->() { return &self; } + const LDKAcceptChannel* operator &() const { return &self; } + const LDKAcceptChannel* operator ->() const { return &self; } }; -class FailureCode { +class AcceptChannelV2 { private: - LDKFailureCode self; + LDKAcceptChannelV2 self; public: - FailureCode(const FailureCode&) = delete; - FailureCode(FailureCode&& o) : self(o.self) { memset(&o, 0, sizeof(FailureCode)); } - FailureCode(LDKFailureCode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFailureCode)); } - operator LDKFailureCode() && { LDKFailureCode res = self; memset(&self, 0, sizeof(LDKFailureCode)); return res; } - FailureCode& operator=(FailureCode&& o) { self = o.self; memset(&o, 0, sizeof(FailureCode)); return *this; } - LDKFailureCode* operator &() { return &self; } - LDKFailureCode* operator ->() { return &self; } - const LDKFailureCode* operator &() const { return &self; } - const LDKFailureCode* operator ->() const { return &self; } + AcceptChannelV2(const AcceptChannelV2&) = delete; + AcceptChannelV2(AcceptChannelV2&& o) : self(o.self) { memset(&o, 0, sizeof(AcceptChannelV2)); } + AcceptChannelV2(LDKAcceptChannelV2&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAcceptChannelV2)); } + operator LDKAcceptChannelV2() && { LDKAcceptChannelV2 res = self; memset(&self, 0, sizeof(LDKAcceptChannelV2)); return res; } + ~AcceptChannelV2() { AcceptChannelV2_free(self); } + AcceptChannelV2& operator=(AcceptChannelV2&& o) { AcceptChannelV2_free(self); self = o.self; memset(&o, 0, sizeof(AcceptChannelV2)); return *this; } + LDKAcceptChannelV2* operator &() { return &self; } + LDKAcceptChannelV2* operator ->() { return &self; } + const LDKAcceptChannelV2* operator &() const { return &self; } + const LDKAcceptChannelV2* operator ->() const { return &self; } }; -class ChannelManager { +class FundingCreated { private: - LDKChannelManager self; + LDKFundingCreated self; public: - ChannelManager(const ChannelManager&) = delete; - ChannelManager(ChannelManager&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManager)); } - ChannelManager(LDKChannelManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManager)); } - operator LDKChannelManager() && { LDKChannelManager res = self; memset(&self, 0, sizeof(LDKChannelManager)); return res; } - ~ChannelManager() { ChannelManager_free(self); } - ChannelManager& operator=(ChannelManager&& o) { ChannelManager_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManager)); return *this; } - LDKChannelManager* operator &() { return &self; } - LDKChannelManager* operator ->() { return &self; } - const LDKChannelManager* operator &() const { return &self; } - const LDKChannelManager* operator ->() const { return &self; } + FundingCreated(const FundingCreated&) = delete; + FundingCreated(FundingCreated&& o) : self(o.self) { memset(&o, 0, sizeof(FundingCreated)); } + FundingCreated(LDKFundingCreated&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingCreated)); } + operator LDKFundingCreated() && { LDKFundingCreated res = self; memset(&self, 0, sizeof(LDKFundingCreated)); return res; } + ~FundingCreated() { FundingCreated_free(self); } + FundingCreated& operator=(FundingCreated&& o) { FundingCreated_free(self); self = o.self; memset(&o, 0, sizeof(FundingCreated)); return *this; } + LDKFundingCreated* operator &() { return &self; } + LDKFundingCreated* operator ->() { return &self; } + const LDKFundingCreated* operator &() const { return &self; } + const LDKFundingCreated* operator ->() const { return &self; } +}; +class FundingSigned { +private: + LDKFundingSigned self; +public: + FundingSigned(const FundingSigned&) = delete; + FundingSigned(FundingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(FundingSigned)); } + FundingSigned(LDKFundingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingSigned)); } + operator LDKFundingSigned() && { LDKFundingSigned res = self; memset(&self, 0, sizeof(LDKFundingSigned)); return res; } + ~FundingSigned() { FundingSigned_free(self); } + FundingSigned& operator=(FundingSigned&& o) { FundingSigned_free(self); self = o.self; memset(&o, 0, sizeof(FundingSigned)); return *this; } + LDKFundingSigned* operator &() { return &self; } + LDKFundingSigned* operator ->() { return &self; } + const LDKFundingSigned* operator &() const { return &self; } + const LDKFundingSigned* operator ->() const { return &self; } +}; +class ChannelReady { +private: + LDKChannelReady self; +public: + ChannelReady(const ChannelReady&) = delete; + ChannelReady(ChannelReady&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelReady)); } + ChannelReady(LDKChannelReady&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelReady)); } + operator LDKChannelReady() && { LDKChannelReady res = self; memset(&self, 0, sizeof(LDKChannelReady)); return res; } + ~ChannelReady() { ChannelReady_free(self); } + ChannelReady& operator=(ChannelReady&& o) { ChannelReady_free(self); self = o.self; memset(&o, 0, sizeof(ChannelReady)); return *this; } + LDKChannelReady* operator &() { return &self; } + LDKChannelReady* operator ->() { return &self; } + const LDKChannelReady* operator &() const { return &self; } + const LDKChannelReady* operator ->() const { return &self; } +}; +class TxAddInput { +private: + LDKTxAddInput self; +public: + TxAddInput(const TxAddInput&) = delete; + TxAddInput(TxAddInput&& o) : self(o.self) { memset(&o, 0, sizeof(TxAddInput)); } + TxAddInput(LDKTxAddInput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxAddInput)); } + operator LDKTxAddInput() && { LDKTxAddInput res = self; memset(&self, 0, sizeof(LDKTxAddInput)); return res; } + ~TxAddInput() { TxAddInput_free(self); } + TxAddInput& operator=(TxAddInput&& o) { TxAddInput_free(self); self = o.self; memset(&o, 0, sizeof(TxAddInput)); return *this; } + LDKTxAddInput* operator &() { return &self; } + LDKTxAddInput* operator ->() { return &self; } + const LDKTxAddInput* operator &() const { return &self; } + const LDKTxAddInput* operator ->() const { return &self; } +}; +class TxAddOutput { +private: + LDKTxAddOutput self; +public: + TxAddOutput(const TxAddOutput&) = delete; + TxAddOutput(TxAddOutput&& o) : self(o.self) { memset(&o, 0, sizeof(TxAddOutput)); } + TxAddOutput(LDKTxAddOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxAddOutput)); } + operator LDKTxAddOutput() && { LDKTxAddOutput res = self; memset(&self, 0, sizeof(LDKTxAddOutput)); return res; } + ~TxAddOutput() { TxAddOutput_free(self); } + TxAddOutput& operator=(TxAddOutput&& o) { TxAddOutput_free(self); self = o.self; memset(&o, 0, sizeof(TxAddOutput)); return *this; } + LDKTxAddOutput* operator &() { return &self; } + LDKTxAddOutput* operator ->() { return &self; } + const LDKTxAddOutput* operator &() const { return &self; } + const LDKTxAddOutput* operator ->() const { return &self; } +}; +class TxRemoveInput { +private: + LDKTxRemoveInput self; +public: + TxRemoveInput(const TxRemoveInput&) = delete; + TxRemoveInput(TxRemoveInput&& o) : self(o.self) { memset(&o, 0, sizeof(TxRemoveInput)); } + TxRemoveInput(LDKTxRemoveInput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxRemoveInput)); } + operator LDKTxRemoveInput() && { LDKTxRemoveInput res = self; memset(&self, 0, sizeof(LDKTxRemoveInput)); return res; } + ~TxRemoveInput() { TxRemoveInput_free(self); } + TxRemoveInput& operator=(TxRemoveInput&& o) { TxRemoveInput_free(self); self = o.self; memset(&o, 0, sizeof(TxRemoveInput)); return *this; } + LDKTxRemoveInput* operator &() { return &self; } + LDKTxRemoveInput* operator ->() { return &self; } + const LDKTxRemoveInput* operator &() const { return &self; } + const LDKTxRemoveInput* operator ->() const { return &self; } +}; +class TxRemoveOutput { +private: + LDKTxRemoveOutput self; +public: + TxRemoveOutput(const TxRemoveOutput&) = delete; + TxRemoveOutput(TxRemoveOutput&& o) : self(o.self) { memset(&o, 0, sizeof(TxRemoveOutput)); } + TxRemoveOutput(LDKTxRemoveOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxRemoveOutput)); } + operator LDKTxRemoveOutput() && { LDKTxRemoveOutput res = self; memset(&self, 0, sizeof(LDKTxRemoveOutput)); return res; } + ~TxRemoveOutput() { TxRemoveOutput_free(self); } + TxRemoveOutput& operator=(TxRemoveOutput&& o) { TxRemoveOutput_free(self); self = o.self; memset(&o, 0, sizeof(TxRemoveOutput)); return *this; } + LDKTxRemoveOutput* operator &() { return &self; } + LDKTxRemoveOutput* operator ->() { return &self; } + const LDKTxRemoveOutput* operator &() const { return &self; } + const LDKTxRemoveOutput* operator ->() const { return &self; } +}; +class TxComplete { +private: + LDKTxComplete self; +public: + TxComplete(const TxComplete&) = delete; + TxComplete(TxComplete&& o) : self(o.self) { memset(&o, 0, sizeof(TxComplete)); } + TxComplete(LDKTxComplete&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxComplete)); } + operator LDKTxComplete() && { LDKTxComplete res = self; memset(&self, 0, sizeof(LDKTxComplete)); return res; } + ~TxComplete() { TxComplete_free(self); } + TxComplete& operator=(TxComplete&& o) { TxComplete_free(self); self = o.self; memset(&o, 0, sizeof(TxComplete)); return *this; } + LDKTxComplete* operator &() { return &self; } + LDKTxComplete* operator ->() { return &self; } + const LDKTxComplete* operator &() const { return &self; } + const LDKTxComplete* operator ->() const { return &self; } +}; +class TxSignatures { +private: + LDKTxSignatures self; +public: + TxSignatures(const TxSignatures&) = delete; + TxSignatures(TxSignatures&& o) : self(o.self) { memset(&o, 0, sizeof(TxSignatures)); } + TxSignatures(LDKTxSignatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxSignatures)); } + operator LDKTxSignatures() && { LDKTxSignatures res = self; memset(&self, 0, sizeof(LDKTxSignatures)); return res; } + ~TxSignatures() { TxSignatures_free(self); } + TxSignatures& operator=(TxSignatures&& o) { TxSignatures_free(self); self = o.self; memset(&o, 0, sizeof(TxSignatures)); return *this; } + LDKTxSignatures* operator &() { return &self; } + LDKTxSignatures* operator ->() { return &self; } + const LDKTxSignatures* operator &() const { return &self; } + const LDKTxSignatures* operator ->() const { return &self; } +}; +class TxInitRbf { +private: + LDKTxInitRbf self; +public: + TxInitRbf(const TxInitRbf&) = delete; + TxInitRbf(TxInitRbf&& o) : self(o.self) { memset(&o, 0, sizeof(TxInitRbf)); } + TxInitRbf(LDKTxInitRbf&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxInitRbf)); } + operator LDKTxInitRbf() && { LDKTxInitRbf res = self; memset(&self, 0, sizeof(LDKTxInitRbf)); return res; } + ~TxInitRbf() { TxInitRbf_free(self); } + TxInitRbf& operator=(TxInitRbf&& o) { TxInitRbf_free(self); self = o.self; memset(&o, 0, sizeof(TxInitRbf)); return *this; } + LDKTxInitRbf* operator &() { return &self; } + LDKTxInitRbf* operator ->() { return &self; } + const LDKTxInitRbf* operator &() const { return &self; } + const LDKTxInitRbf* operator ->() const { return &self; } +}; +class TxAckRbf { +private: + LDKTxAckRbf self; +public: + TxAckRbf(const TxAckRbf&) = delete; + TxAckRbf(TxAckRbf&& o) : self(o.self) { memset(&o, 0, sizeof(TxAckRbf)); } + TxAckRbf(LDKTxAckRbf&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxAckRbf)); } + operator LDKTxAckRbf() && { LDKTxAckRbf res = self; memset(&self, 0, sizeof(LDKTxAckRbf)); return res; } + ~TxAckRbf() { TxAckRbf_free(self); } + TxAckRbf& operator=(TxAckRbf&& o) { TxAckRbf_free(self); self = o.self; memset(&o, 0, sizeof(TxAckRbf)); return *this; } + LDKTxAckRbf* operator &() { return &self; } + LDKTxAckRbf* operator ->() { return &self; } + const LDKTxAckRbf* operator &() const { return &self; } + const LDKTxAckRbf* operator ->() const { return &self; } +}; +class TxAbort { +private: + LDKTxAbort self; +public: + TxAbort(const TxAbort&) = delete; + TxAbort(TxAbort&& o) : self(o.self) { memset(&o, 0, sizeof(TxAbort)); } + TxAbort(LDKTxAbort&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxAbort)); } + operator LDKTxAbort() && { LDKTxAbort res = self; memset(&self, 0, sizeof(LDKTxAbort)); return res; } + ~TxAbort() { TxAbort_free(self); } + TxAbort& operator=(TxAbort&& o) { TxAbort_free(self); self = o.self; memset(&o, 0, sizeof(TxAbort)); return *this; } + LDKTxAbort* operator &() { return &self; } + LDKTxAbort* operator ->() { return &self; } + const LDKTxAbort* operator &() const { return &self; } + const LDKTxAbort* operator ->() const { return &self; } +}; +class Shutdown { +private: + LDKShutdown self; +public: + Shutdown(const Shutdown&) = delete; + Shutdown(Shutdown&& o) : self(o.self) { memset(&o, 0, sizeof(Shutdown)); } + Shutdown(LDKShutdown&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShutdown)); } + operator LDKShutdown() && { LDKShutdown res = self; memset(&self, 0, sizeof(LDKShutdown)); return res; } + ~Shutdown() { Shutdown_free(self); } + Shutdown& operator=(Shutdown&& o) { Shutdown_free(self); self = o.self; memset(&o, 0, sizeof(Shutdown)); return *this; } + LDKShutdown* operator &() { return &self; } + LDKShutdown* operator ->() { return &self; } + const LDKShutdown* operator &() const { return &self; } + const LDKShutdown* operator ->() const { return &self; } +}; +class ClosingSignedFeeRange { +private: + LDKClosingSignedFeeRange self; +public: + ClosingSignedFeeRange(const ClosingSignedFeeRange&) = delete; + ClosingSignedFeeRange(ClosingSignedFeeRange&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingSignedFeeRange)); } + ClosingSignedFeeRange(LDKClosingSignedFeeRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingSignedFeeRange)); } + operator LDKClosingSignedFeeRange() && { LDKClosingSignedFeeRange res = self; memset(&self, 0, sizeof(LDKClosingSignedFeeRange)); return res; } + ~ClosingSignedFeeRange() { ClosingSignedFeeRange_free(self); } + ClosingSignedFeeRange& operator=(ClosingSignedFeeRange&& o) { ClosingSignedFeeRange_free(self); self = o.self; memset(&o, 0, sizeof(ClosingSignedFeeRange)); return *this; } + LDKClosingSignedFeeRange* operator &() { return &self; } + LDKClosingSignedFeeRange* operator ->() { return &self; } + const LDKClosingSignedFeeRange* operator &() const { return &self; } + const LDKClosingSignedFeeRange* operator ->() const { return &self; } }; -class ChainParameters { +class ClosingSigned { private: - LDKChainParameters self; + LDKClosingSigned self; public: - ChainParameters(const ChainParameters&) = delete; - ChainParameters(ChainParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChainParameters)); } - ChainParameters(LDKChainParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainParameters)); } - operator LDKChainParameters() && { LDKChainParameters res = self; memset(&self, 0, sizeof(LDKChainParameters)); return res; } - ~ChainParameters() { ChainParameters_free(self); } - ChainParameters& operator=(ChainParameters&& o) { ChainParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChainParameters)); return *this; } - LDKChainParameters* operator &() { return &self; } - LDKChainParameters* operator ->() { return &self; } - const LDKChainParameters* operator &() const { return &self; } - const LDKChainParameters* operator ->() const { return &self; } + ClosingSigned(const ClosingSigned&) = delete; + ClosingSigned(ClosingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingSigned)); } + ClosingSigned(LDKClosingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingSigned)); } + operator LDKClosingSigned() && { LDKClosingSigned res = self; memset(&self, 0, sizeof(LDKClosingSigned)); return res; } + ~ClosingSigned() { ClosingSigned_free(self); } + ClosingSigned& operator=(ClosingSigned&& o) { ClosingSigned_free(self); self = o.self; memset(&o, 0, sizeof(ClosingSigned)); return *this; } + LDKClosingSigned* operator &() { return &self; } + LDKClosingSigned* operator ->() { return &self; } + const LDKClosingSigned* operator &() const { return &self; } + const LDKClosingSigned* operator ->() const { return &self; } }; -class CounterpartyForwardingInfo { +class UpdateAddHTLC { private: - LDKCounterpartyForwardingInfo self; + LDKUpdateAddHTLC self; public: - CounterpartyForwardingInfo(const CounterpartyForwardingInfo&) = delete; - CounterpartyForwardingInfo(CounterpartyForwardingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyForwardingInfo)); } - CounterpartyForwardingInfo(LDKCounterpartyForwardingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyForwardingInfo)); } - operator LDKCounterpartyForwardingInfo() && { LDKCounterpartyForwardingInfo res = self; memset(&self, 0, sizeof(LDKCounterpartyForwardingInfo)); return res; } - ~CounterpartyForwardingInfo() { CounterpartyForwardingInfo_free(self); } - CounterpartyForwardingInfo& operator=(CounterpartyForwardingInfo&& o) { CounterpartyForwardingInfo_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyForwardingInfo)); return *this; } - LDKCounterpartyForwardingInfo* operator &() { return &self; } - LDKCounterpartyForwardingInfo* operator ->() { return &self; } - const LDKCounterpartyForwardingInfo* operator &() const { return &self; } - const LDKCounterpartyForwardingInfo* operator ->() const { return &self; } + UpdateAddHTLC(const UpdateAddHTLC&) = delete; + UpdateAddHTLC(UpdateAddHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateAddHTLC)); } + UpdateAddHTLC(LDKUpdateAddHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateAddHTLC)); } + operator LDKUpdateAddHTLC() && { LDKUpdateAddHTLC res = self; memset(&self, 0, sizeof(LDKUpdateAddHTLC)); return res; } + ~UpdateAddHTLC() { UpdateAddHTLC_free(self); } + UpdateAddHTLC& operator=(UpdateAddHTLC&& o) { UpdateAddHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateAddHTLC)); return *this; } + LDKUpdateAddHTLC* operator &() { return &self; } + LDKUpdateAddHTLC* operator ->() { return &self; } + const LDKUpdateAddHTLC* operator &() const { return &self; } + const LDKUpdateAddHTLC* operator ->() const { return &self; } }; -class ChannelCounterparty { +class OnionMessage { private: - LDKChannelCounterparty self; + LDKOnionMessage self; public: - ChannelCounterparty(const ChannelCounterparty&) = delete; - ChannelCounterparty(ChannelCounterparty&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelCounterparty)); } - ChannelCounterparty(LDKChannelCounterparty&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelCounterparty)); } - operator LDKChannelCounterparty() && { LDKChannelCounterparty res = self; memset(&self, 0, sizeof(LDKChannelCounterparty)); return res; } - ~ChannelCounterparty() { ChannelCounterparty_free(self); } - ChannelCounterparty& operator=(ChannelCounterparty&& o) { ChannelCounterparty_free(self); self = o.self; memset(&o, 0, sizeof(ChannelCounterparty)); return *this; } - LDKChannelCounterparty* operator &() { return &self; } - LDKChannelCounterparty* operator ->() { return &self; } - const LDKChannelCounterparty* operator &() const { return &self; } - const LDKChannelCounterparty* operator ->() const { return &self; } + OnionMessage(const OnionMessage&) = delete; + OnionMessage(OnionMessage&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessage)); } + OnionMessage(LDKOnionMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessage)); } + operator LDKOnionMessage() && { LDKOnionMessage res = self; memset(&self, 0, sizeof(LDKOnionMessage)); return res; } + ~OnionMessage() { OnionMessage_free(self); } + OnionMessage& operator=(OnionMessage&& o) { OnionMessage_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessage)); return *this; } + LDKOnionMessage* operator &() { return &self; } + LDKOnionMessage* operator ->() { return &self; } + const LDKOnionMessage* operator &() const { return &self; } + const LDKOnionMessage* operator ->() const { return &self; } }; -class ChannelDetails { +class UpdateFulfillHTLC { private: - LDKChannelDetails self; + LDKUpdateFulfillHTLC self; public: - ChannelDetails(const ChannelDetails&) = delete; - ChannelDetails(ChannelDetails&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDetails)); } - ChannelDetails(LDKChannelDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDetails)); } - operator LDKChannelDetails() && { LDKChannelDetails res = self; memset(&self, 0, sizeof(LDKChannelDetails)); return res; } - ~ChannelDetails() { ChannelDetails_free(self); } - ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } - LDKChannelDetails* operator &() { return &self; } - LDKChannelDetails* operator ->() { return &self; } - const LDKChannelDetails* operator &() const { return &self; } - const LDKChannelDetails* operator ->() const { return &self; } + UpdateFulfillHTLC(const UpdateFulfillHTLC&) = delete; + UpdateFulfillHTLC(UpdateFulfillHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFulfillHTLC)); } + UpdateFulfillHTLC(LDKUpdateFulfillHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFulfillHTLC)); } + operator LDKUpdateFulfillHTLC() && { LDKUpdateFulfillHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFulfillHTLC)); return res; } + ~UpdateFulfillHTLC() { UpdateFulfillHTLC_free(self); } + UpdateFulfillHTLC& operator=(UpdateFulfillHTLC&& o) { UpdateFulfillHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFulfillHTLC)); return *this; } + LDKUpdateFulfillHTLC* operator &() { return &self; } + LDKUpdateFulfillHTLC* operator ->() { return &self; } + const LDKUpdateFulfillHTLC* operator &() const { return &self; } + const LDKUpdateFulfillHTLC* operator ->() const { return &self; } }; -class RecentPaymentDetails { +class UpdateFailHTLC { private: - LDKRecentPaymentDetails self; + LDKUpdateFailHTLC self; public: - RecentPaymentDetails(const RecentPaymentDetails&) = delete; - RecentPaymentDetails(RecentPaymentDetails&& o) : self(o.self) { memset(&o, 0, sizeof(RecentPaymentDetails)); } - RecentPaymentDetails(LDKRecentPaymentDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecentPaymentDetails)); } - operator LDKRecentPaymentDetails() && { LDKRecentPaymentDetails res = self; memset(&self, 0, sizeof(LDKRecentPaymentDetails)); return res; } - ~RecentPaymentDetails() { RecentPaymentDetails_free(self); } - RecentPaymentDetails& operator=(RecentPaymentDetails&& o) { RecentPaymentDetails_free(self); self = o.self; memset(&o, 0, sizeof(RecentPaymentDetails)); return *this; } - LDKRecentPaymentDetails* operator &() { return &self; } - LDKRecentPaymentDetails* operator ->() { return &self; } - const LDKRecentPaymentDetails* operator &() const { return &self; } - const LDKRecentPaymentDetails* operator ->() const { return &self; } + UpdateFailHTLC(const UpdateFailHTLC&) = delete; + UpdateFailHTLC(UpdateFailHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailHTLC)); } + UpdateFailHTLC(LDKUpdateFailHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailHTLC)); } + operator LDKUpdateFailHTLC() && { LDKUpdateFailHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailHTLC)); return res; } + ~UpdateFailHTLC() { UpdateFailHTLC_free(self); } + UpdateFailHTLC& operator=(UpdateFailHTLC&& o) { UpdateFailHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFailHTLC)); return *this; } + LDKUpdateFailHTLC* operator &() { return &self; } + LDKUpdateFailHTLC* operator ->() { return &self; } + const LDKUpdateFailHTLC* operator &() const { return &self; } + const LDKUpdateFailHTLC* operator ->() const { return &self; } }; -class PhantomRouteHints { +class UpdateFailMalformedHTLC { private: - LDKPhantomRouteHints self; + LDKUpdateFailMalformedHTLC self; public: - PhantomRouteHints(const PhantomRouteHints&) = delete; - PhantomRouteHints(PhantomRouteHints&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomRouteHints)); } - PhantomRouteHints(LDKPhantomRouteHints&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomRouteHints)); } - operator LDKPhantomRouteHints() && { LDKPhantomRouteHints res = self; memset(&self, 0, sizeof(LDKPhantomRouteHints)); return res; } - ~PhantomRouteHints() { PhantomRouteHints_free(self); } - PhantomRouteHints& operator=(PhantomRouteHints&& o) { PhantomRouteHints_free(self); self = o.self; memset(&o, 0, sizeof(PhantomRouteHints)); return *this; } - LDKPhantomRouteHints* operator &() { return &self; } - LDKPhantomRouteHints* operator ->() { return &self; } - const LDKPhantomRouteHints* operator &() const { return &self; } - const LDKPhantomRouteHints* operator ->() const { return &self; } + UpdateFailMalformedHTLC(const UpdateFailMalformedHTLC&) = delete; + UpdateFailMalformedHTLC(UpdateFailMalformedHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailMalformedHTLC)); } + UpdateFailMalformedHTLC(LDKUpdateFailMalformedHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailMalformedHTLC)); } + operator LDKUpdateFailMalformedHTLC() && { LDKUpdateFailMalformedHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailMalformedHTLC)); return res; } + ~UpdateFailMalformedHTLC() { UpdateFailMalformedHTLC_free(self); } + UpdateFailMalformedHTLC& operator=(UpdateFailMalformedHTLC&& o) { UpdateFailMalformedHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFailMalformedHTLC)); return *this; } + LDKUpdateFailMalformedHTLC* operator &() { return &self; } + LDKUpdateFailMalformedHTLC* operator ->() { return &self; } + const LDKUpdateFailMalformedHTLC* operator &() const { return &self; } + const LDKUpdateFailMalformedHTLC* operator ->() const { return &self; } }; -class ChannelManagerReadArgs { +class CommitmentSigned { private: - LDKChannelManagerReadArgs self; + LDKCommitmentSigned self; public: - ChannelManagerReadArgs(const ChannelManagerReadArgs&) = delete; - ChannelManagerReadArgs(ChannelManagerReadArgs&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelManagerReadArgs)); } - ChannelManagerReadArgs(LDKChannelManagerReadArgs&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelManagerReadArgs)); } - operator LDKChannelManagerReadArgs() && { LDKChannelManagerReadArgs res = self; memset(&self, 0, sizeof(LDKChannelManagerReadArgs)); return res; } - ~ChannelManagerReadArgs() { ChannelManagerReadArgs_free(self); } - ChannelManagerReadArgs& operator=(ChannelManagerReadArgs&& o) { ChannelManagerReadArgs_free(self); self = o.self; memset(&o, 0, sizeof(ChannelManagerReadArgs)); return *this; } - LDKChannelManagerReadArgs* operator &() { return &self; } - LDKChannelManagerReadArgs* operator ->() { return &self; } - const LDKChannelManagerReadArgs* operator &() const { return &self; } - const LDKChannelManagerReadArgs* operator ->() const { return &self; } + CommitmentSigned(const CommitmentSigned&) = delete; + CommitmentSigned(CommitmentSigned&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentSigned)); } + CommitmentSigned(LDKCommitmentSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentSigned)); } + operator LDKCommitmentSigned() && { LDKCommitmentSigned res = self; memset(&self, 0, sizeof(LDKCommitmentSigned)); return res; } + ~CommitmentSigned() { CommitmentSigned_free(self); } + CommitmentSigned& operator=(CommitmentSigned&& o) { CommitmentSigned_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentSigned)); return *this; } + LDKCommitmentSigned* operator &() { return &self; } + LDKCommitmentSigned* operator ->() { return &self; } + const LDKCommitmentSigned* operator &() const { return &self; } + const LDKCommitmentSigned* operator ->() const { return &self; } }; -class ChannelHandshakeConfig { +class RevokeAndACK { private: - LDKChannelHandshakeConfig self; + LDKRevokeAndACK self; public: - ChannelHandshakeConfig(const ChannelHandshakeConfig&) = delete; - ChannelHandshakeConfig(ChannelHandshakeConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeConfig)); } - ChannelHandshakeConfig(LDKChannelHandshakeConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeConfig)); } - operator LDKChannelHandshakeConfig() && { LDKChannelHandshakeConfig res = self; memset(&self, 0, sizeof(LDKChannelHandshakeConfig)); return res; } - ~ChannelHandshakeConfig() { ChannelHandshakeConfig_free(self); } - ChannelHandshakeConfig& operator=(ChannelHandshakeConfig&& o) { ChannelHandshakeConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeConfig)); return *this; } - LDKChannelHandshakeConfig* operator &() { return &self; } - LDKChannelHandshakeConfig* operator ->() { return &self; } - const LDKChannelHandshakeConfig* operator &() const { return &self; } - const LDKChannelHandshakeConfig* operator ->() const { return &self; } + RevokeAndACK(const RevokeAndACK&) = delete; + RevokeAndACK(RevokeAndACK&& o) : self(o.self) { memset(&o, 0, sizeof(RevokeAndACK)); } + RevokeAndACK(LDKRevokeAndACK&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRevokeAndACK)); } + operator LDKRevokeAndACK() && { LDKRevokeAndACK res = self; memset(&self, 0, sizeof(LDKRevokeAndACK)); return res; } + ~RevokeAndACK() { RevokeAndACK_free(self); } + RevokeAndACK& operator=(RevokeAndACK&& o) { RevokeAndACK_free(self); self = o.self; memset(&o, 0, sizeof(RevokeAndACK)); return *this; } + LDKRevokeAndACK* operator &() { return &self; } + LDKRevokeAndACK* operator ->() { return &self; } + const LDKRevokeAndACK* operator &() const { return &self; } + const LDKRevokeAndACK* operator ->() const { return &self; } }; -class ChannelHandshakeLimits { +class UpdateFee { private: - LDKChannelHandshakeLimits self; + LDKUpdateFee self; public: - ChannelHandshakeLimits(const ChannelHandshakeLimits&) = delete; - ChannelHandshakeLimits(ChannelHandshakeLimits&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelHandshakeLimits)); } - ChannelHandshakeLimits(LDKChannelHandshakeLimits&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelHandshakeLimits)); } - operator LDKChannelHandshakeLimits() && { LDKChannelHandshakeLimits res = self; memset(&self, 0, sizeof(LDKChannelHandshakeLimits)); return res; } - ~ChannelHandshakeLimits() { ChannelHandshakeLimits_free(self); } - ChannelHandshakeLimits& operator=(ChannelHandshakeLimits&& o) { ChannelHandshakeLimits_free(self); self = o.self; memset(&o, 0, sizeof(ChannelHandshakeLimits)); return *this; } - LDKChannelHandshakeLimits* operator &() { return &self; } - LDKChannelHandshakeLimits* operator ->() { return &self; } - const LDKChannelHandshakeLimits* operator &() const { return &self; } - const LDKChannelHandshakeLimits* operator ->() const { return &self; } + UpdateFee(const UpdateFee&) = delete; + UpdateFee(UpdateFee&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFee)); } + UpdateFee(LDKUpdateFee&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFee)); } + operator LDKUpdateFee() && { LDKUpdateFee res = self; memset(&self, 0, sizeof(LDKUpdateFee)); return res; } + ~UpdateFee() { UpdateFee_free(self); } + UpdateFee& operator=(UpdateFee&& o) { UpdateFee_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFee)); return *this; } + LDKUpdateFee* operator &() { return &self; } + LDKUpdateFee* operator ->() { return &self; } + const LDKUpdateFee* operator &() const { return &self; } + const LDKUpdateFee* operator ->() const { return &self; } }; -class ChannelConfig { +class ChannelReestablish { private: - LDKChannelConfig self; + LDKChannelReestablish self; public: - ChannelConfig(const ChannelConfig&) = delete; - ChannelConfig(ChannelConfig&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelConfig)); } - ChannelConfig(LDKChannelConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelConfig)); } - operator LDKChannelConfig() && { LDKChannelConfig res = self; memset(&self, 0, sizeof(LDKChannelConfig)); return res; } - ~ChannelConfig() { ChannelConfig_free(self); } - ChannelConfig& operator=(ChannelConfig&& o) { ChannelConfig_free(self); self = o.self; memset(&o, 0, sizeof(ChannelConfig)); return *this; } - LDKChannelConfig* operator &() { return &self; } - LDKChannelConfig* operator ->() { return &self; } - const LDKChannelConfig* operator &() const { return &self; } - const LDKChannelConfig* operator ->() const { return &self; } + ChannelReestablish(const ChannelReestablish&) = delete; + ChannelReestablish(ChannelReestablish&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelReestablish)); } + ChannelReestablish(LDKChannelReestablish&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelReestablish)); } + operator LDKChannelReestablish() && { LDKChannelReestablish res = self; memset(&self, 0, sizeof(LDKChannelReestablish)); return res; } + ~ChannelReestablish() { ChannelReestablish_free(self); } + ChannelReestablish& operator=(ChannelReestablish&& o) { ChannelReestablish_free(self); self = o.self; memset(&o, 0, sizeof(ChannelReestablish)); return *this; } + LDKChannelReestablish* operator &() { return &self; } + LDKChannelReestablish* operator ->() { return &self; } + const LDKChannelReestablish* operator &() const { return &self; } + const LDKChannelReestablish* operator ->() const { return &self; } }; -class UserConfig { +class AnnouncementSignatures { +private: + LDKAnnouncementSignatures self; +public: + AnnouncementSignatures(const AnnouncementSignatures&) = delete; + AnnouncementSignatures(AnnouncementSignatures&& o) : self(o.self) { memset(&o, 0, sizeof(AnnouncementSignatures)); } + AnnouncementSignatures(LDKAnnouncementSignatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAnnouncementSignatures)); } + operator LDKAnnouncementSignatures() && { LDKAnnouncementSignatures res = self; memset(&self, 0, sizeof(LDKAnnouncementSignatures)); return res; } + ~AnnouncementSignatures() { AnnouncementSignatures_free(self); } + AnnouncementSignatures& operator=(AnnouncementSignatures&& o) { AnnouncementSignatures_free(self); self = o.self; memset(&o, 0, sizeof(AnnouncementSignatures)); return *this; } + LDKAnnouncementSignatures* operator &() { return &self; } + LDKAnnouncementSignatures* operator ->() { return &self; } + const LDKAnnouncementSignatures* operator &() const { return &self; } + const LDKAnnouncementSignatures* operator ->() const { return &self; } +}; +class NetAddress { private: - LDKUserConfig self; + LDKNetAddress self; public: - UserConfig(const UserConfig&) = delete; - UserConfig(UserConfig&& o) : self(o.self) { memset(&o, 0, sizeof(UserConfig)); } - UserConfig(LDKUserConfig&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUserConfig)); } - operator LDKUserConfig() && { LDKUserConfig res = self; memset(&self, 0, sizeof(LDKUserConfig)); return res; } - ~UserConfig() { UserConfig_free(self); } - UserConfig& operator=(UserConfig&& o) { UserConfig_free(self); self = o.self; memset(&o, 0, sizeof(UserConfig)); return *this; } - LDKUserConfig* operator &() { return &self; } - LDKUserConfig* operator ->() { return &self; } - const LDKUserConfig* operator &() const { return &self; } - const LDKUserConfig* operator ->() const { return &self; } + NetAddress(const NetAddress&) = delete; + NetAddress(NetAddress&& o) : self(o.self) { memset(&o, 0, sizeof(NetAddress)); } + NetAddress(LDKNetAddress&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetAddress)); } + operator LDKNetAddress() && { LDKNetAddress res = self; memset(&self, 0, sizeof(LDKNetAddress)); return res; } + ~NetAddress() { NetAddress_free(self); } + NetAddress& operator=(NetAddress&& o) { NetAddress_free(self); self = o.self; memset(&o, 0, sizeof(NetAddress)); return *this; } + LDKNetAddress* operator &() { return &self; } + LDKNetAddress* operator ->() { return &self; } + const LDKNetAddress* operator &() const { return &self; } + const LDKNetAddress* operator ->() const { return &self; } }; -class APIError { +class UnsignedGossipMessage { private: - LDKAPIError self; + LDKUnsignedGossipMessage self; public: - APIError(const APIError&) = delete; - APIError(APIError&& o) : self(o.self) { memset(&o, 0, sizeof(APIError)); } - APIError(LDKAPIError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAPIError)); } - operator LDKAPIError() && { LDKAPIError res = self; memset(&self, 0, sizeof(LDKAPIError)); return res; } - ~APIError() { APIError_free(self); } - APIError& operator=(APIError&& o) { APIError_free(self); self = o.self; memset(&o, 0, sizeof(APIError)); return *this; } - LDKAPIError* operator &() { return &self; } - LDKAPIError* operator ->() { return &self; } - const LDKAPIError* operator &() const { return &self; } - const LDKAPIError* operator ->() const { return &self; } + UnsignedGossipMessage(const UnsignedGossipMessage&) = delete; + UnsignedGossipMessage(UnsignedGossipMessage&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedGossipMessage)); } + UnsignedGossipMessage(LDKUnsignedGossipMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedGossipMessage)); } + operator LDKUnsignedGossipMessage() && { LDKUnsignedGossipMessage res = self; memset(&self, 0, sizeof(LDKUnsignedGossipMessage)); return res; } + ~UnsignedGossipMessage() { UnsignedGossipMessage_free(self); } + UnsignedGossipMessage& operator=(UnsignedGossipMessage&& o) { UnsignedGossipMessage_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedGossipMessage)); return *this; } + LDKUnsignedGossipMessage* operator &() { return &self; } + LDKUnsignedGossipMessage* operator ->() { return &self; } + const LDKUnsignedGossipMessage* operator &() const { return &self; } + const LDKUnsignedGossipMessage* operator ->() const { return &self; } }; -class BigSize { +class UnsignedNodeAnnouncement { private: - LDKBigSize self; + LDKUnsignedNodeAnnouncement self; public: - BigSize(const BigSize&) = delete; - BigSize(BigSize&& o) : self(o.self) { memset(&o, 0, sizeof(BigSize)); } - BigSize(LDKBigSize&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBigSize)); } - operator LDKBigSize() && { LDKBigSize res = self; memset(&self, 0, sizeof(LDKBigSize)); return res; } - ~BigSize() { BigSize_free(self); } - BigSize& operator=(BigSize&& o) { BigSize_free(self); self = o.self; memset(&o, 0, sizeof(BigSize)); return *this; } - LDKBigSize* operator &() { return &self; } - LDKBigSize* operator ->() { return &self; } - const LDKBigSize* operator &() const { return &self; } - const LDKBigSize* operator ->() const { return &self; } + UnsignedNodeAnnouncement(const UnsignedNodeAnnouncement&) = delete; + UnsignedNodeAnnouncement(UnsignedNodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedNodeAnnouncement)); } + UnsignedNodeAnnouncement(LDKUnsignedNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedNodeAnnouncement)); } + operator LDKUnsignedNodeAnnouncement() && { LDKUnsignedNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedNodeAnnouncement)); return res; } + ~UnsignedNodeAnnouncement() { UnsignedNodeAnnouncement_free(self); } + UnsignedNodeAnnouncement& operator=(UnsignedNodeAnnouncement&& o) { UnsignedNodeAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedNodeAnnouncement)); return *this; } + LDKUnsignedNodeAnnouncement* operator &() { return &self; } + LDKUnsignedNodeAnnouncement* operator ->() { return &self; } + const LDKUnsignedNodeAnnouncement* operator &() const { return &self; } + const LDKUnsignedNodeAnnouncement* operator ->() const { return &self; } }; -class Hostname { +class NodeAnnouncement { private: - LDKHostname self; + LDKNodeAnnouncement self; public: - Hostname(const Hostname&) = delete; - Hostname(Hostname&& o) : self(o.self) { memset(&o, 0, sizeof(Hostname)); } - Hostname(LDKHostname&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHostname)); } - operator LDKHostname() && { LDKHostname res = self; memset(&self, 0, sizeof(LDKHostname)); return res; } - ~Hostname() { Hostname_free(self); } - Hostname& operator=(Hostname&& o) { Hostname_free(self); self = o.self; memset(&o, 0, sizeof(Hostname)); return *this; } - LDKHostname* operator &() { return &self; } - LDKHostname* operator ->() { return &self; } - const LDKHostname* operator &() const { return &self; } - const LDKHostname* operator ->() const { return &self; } + NodeAnnouncement(const NodeAnnouncement&) = delete; + NodeAnnouncement(NodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncement)); } + NodeAnnouncement(LDKNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncement)); } + operator LDKNodeAnnouncement() && { LDKNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKNodeAnnouncement)); return res; } + ~NodeAnnouncement() { NodeAnnouncement_free(self); } + NodeAnnouncement& operator=(NodeAnnouncement&& o) { NodeAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(NodeAnnouncement)); return *this; } + LDKNodeAnnouncement* operator &() { return &self; } + LDKNodeAnnouncement* operator ->() { return &self; } + const LDKNodeAnnouncement* operator &() const { return &self; } + const LDKNodeAnnouncement* operator ->() const { return &self; } }; -class UntrustedString { +class UnsignedChannelAnnouncement { private: - LDKUntrustedString self; + LDKUnsignedChannelAnnouncement self; public: - UntrustedString(const UntrustedString&) = delete; - UntrustedString(UntrustedString&& o) : self(o.self) { memset(&o, 0, sizeof(UntrustedString)); } - UntrustedString(LDKUntrustedString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUntrustedString)); } - operator LDKUntrustedString() && { LDKUntrustedString res = self; memset(&self, 0, sizeof(LDKUntrustedString)); return res; } - ~UntrustedString() { UntrustedString_free(self); } - UntrustedString& operator=(UntrustedString&& o) { UntrustedString_free(self); self = o.self; memset(&o, 0, sizeof(UntrustedString)); return *this; } - LDKUntrustedString* operator &() { return &self; } - LDKUntrustedString* operator ->() { return &self; } - const LDKUntrustedString* operator &() const { return &self; } - const LDKUntrustedString* operator ->() const { return &self; } + UnsignedChannelAnnouncement(const UnsignedChannelAnnouncement&) = delete; + UnsignedChannelAnnouncement(UnsignedChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelAnnouncement)); } + UnsignedChannelAnnouncement(LDKUnsignedChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelAnnouncement)); } + operator LDKUnsignedChannelAnnouncement() && { LDKUnsignedChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedChannelAnnouncement)); return res; } + ~UnsignedChannelAnnouncement() { UnsignedChannelAnnouncement_free(self); } + UnsignedChannelAnnouncement& operator=(UnsignedChannelAnnouncement&& o) { UnsignedChannelAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedChannelAnnouncement)); return *this; } + LDKUnsignedChannelAnnouncement* operator &() { return &self; } + LDKUnsignedChannelAnnouncement* operator ->() { return &self; } + const LDKUnsignedChannelAnnouncement* operator &() const { return &self; } + const LDKUnsignedChannelAnnouncement* operator ->() const { return &self; } }; -class PrintableString { +class ChannelAnnouncement { private: - LDKPrintableString self; + LDKChannelAnnouncement self; public: - PrintableString(const PrintableString&) = delete; - PrintableString(PrintableString&& o) : self(o.self) { memset(&o, 0, sizeof(PrintableString)); } - PrintableString(LDKPrintableString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrintableString)); } - operator LDKPrintableString() && { LDKPrintableString res = self; memset(&self, 0, sizeof(LDKPrintableString)); return res; } - ~PrintableString() { PrintableString_free(self); } - PrintableString& operator=(PrintableString&& o) { PrintableString_free(self); self = o.self; memset(&o, 0, sizeof(PrintableString)); return *this; } - LDKPrintableString* operator &() { return &self; } - LDKPrintableString* operator ->() { return &self; } - const LDKPrintableString* operator &() const { return &self; } - const LDKPrintableString* operator ->() const { return &self; } + ChannelAnnouncement(const ChannelAnnouncement&) = delete; + ChannelAnnouncement(ChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelAnnouncement)); } + ChannelAnnouncement(LDKChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelAnnouncement)); } + operator LDKChannelAnnouncement() && { LDKChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKChannelAnnouncement)); return res; } + ~ChannelAnnouncement() { ChannelAnnouncement_free(self); } + ChannelAnnouncement& operator=(ChannelAnnouncement&& o) { ChannelAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(ChannelAnnouncement)); return *this; } + LDKChannelAnnouncement* operator &() { return &self; } + LDKChannelAnnouncement* operator ->() { return &self; } + const LDKChannelAnnouncement* operator &() const { return &self; } + const LDKChannelAnnouncement* operator ->() const { return &self; } }; -class OutPoint { +class UnsignedChannelUpdate { private: - LDKOutPoint self; + LDKUnsignedChannelUpdate self; public: - OutPoint(const OutPoint&) = delete; - OutPoint(OutPoint&& o) : self(o.self) { memset(&o, 0, sizeof(OutPoint)); } - OutPoint(LDKOutPoint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutPoint)); } - operator LDKOutPoint() && { LDKOutPoint res = self; memset(&self, 0, sizeof(LDKOutPoint)); return res; } - ~OutPoint() { OutPoint_free(self); } - OutPoint& operator=(OutPoint&& o) { OutPoint_free(self); self = o.self; memset(&o, 0, sizeof(OutPoint)); return *this; } - LDKOutPoint* operator &() { return &self; } - LDKOutPoint* operator ->() { return &self; } - const LDKOutPoint* operator &() const { return &self; } - const LDKOutPoint* operator ->() const { return &self; } + UnsignedChannelUpdate(const UnsignedChannelUpdate&) = delete; + UnsignedChannelUpdate(UnsignedChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelUpdate)); } + UnsignedChannelUpdate(LDKUnsignedChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelUpdate)); } + operator LDKUnsignedChannelUpdate() && { LDKUnsignedChannelUpdate res = self; memset(&self, 0, sizeof(LDKUnsignedChannelUpdate)); return res; } + ~UnsignedChannelUpdate() { UnsignedChannelUpdate_free(self); } + UnsignedChannelUpdate& operator=(UnsignedChannelUpdate&& o) { UnsignedChannelUpdate_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedChannelUpdate)); return *this; } + LDKUnsignedChannelUpdate* operator &() { return &self; } + LDKUnsignedChannelUpdate* operator ->() { return &self; } + const LDKUnsignedChannelUpdate* operator &() const { return &self; } + const LDKUnsignedChannelUpdate* operator ->() const { return &self; } }; -class CustomMessageReader { +class ChannelUpdate { private: - LDKCustomMessageReader self; + LDKChannelUpdate self; public: - CustomMessageReader(const CustomMessageReader&) = delete; - CustomMessageReader(CustomMessageReader&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageReader)); } - CustomMessageReader(LDKCustomMessageReader&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageReader)); } - operator LDKCustomMessageReader() && { LDKCustomMessageReader res = self; memset(&self, 0, sizeof(LDKCustomMessageReader)); return res; } - ~CustomMessageReader() { CustomMessageReader_free(self); } - CustomMessageReader& operator=(CustomMessageReader&& o) { CustomMessageReader_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageReader)); return *this; } - LDKCustomMessageReader* operator &() { return &self; } - LDKCustomMessageReader* operator ->() { return &self; } - const LDKCustomMessageReader* operator &() const { return &self; } - const LDKCustomMessageReader* operator ->() const { return &self; } - /** - * Decodes a custom message to `CustomMessageType`. If the given message type is known to the - * implementation and the message could be decoded, must return `Ok(Some(message))`. If the - * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error - * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. - */ - inline LDK::CResult_COption_TypeZDecodeErrorZ read(uint16_t message_type, struct LDKu8slice buffer); + ChannelUpdate(const ChannelUpdate&) = delete; + ChannelUpdate(ChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUpdate)); } + ChannelUpdate(LDKChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUpdate)); } + operator LDKChannelUpdate() && { LDKChannelUpdate res = self; memset(&self, 0, sizeof(LDKChannelUpdate)); return res; } + ~ChannelUpdate() { ChannelUpdate_free(self); } + ChannelUpdate& operator=(ChannelUpdate&& o) { ChannelUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelUpdate)); return *this; } + LDKChannelUpdate* operator &() { return &self; } + LDKChannelUpdate* operator ->() { return &self; } + const LDKChannelUpdate* operator &() const { return &self; } + const LDKChannelUpdate* operator ->() const { return &self; } }; -class Type { +class QueryChannelRange { private: - LDKType self; + LDKQueryChannelRange self; public: - Type(const Type&) = delete; - Type(Type&& o) : self(o.self) { memset(&o, 0, sizeof(Type)); } - Type(LDKType&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKType)); } - operator LDKType() && { LDKType res = self; memset(&self, 0, sizeof(LDKType)); return res; } - ~Type() { Type_free(self); } - Type& operator=(Type&& o) { Type_free(self); self = o.self; memset(&o, 0, sizeof(Type)); return *this; } - LDKType* operator &() { return &self; } - LDKType* operator ->() { return &self; } - const LDKType* operator &() const { return &self; } - const LDKType* operator ->() const { return &self; } - /** - * Returns the type identifying the message payload. - */ - inline uint16_t type_id(); - /** - * Return a human-readable "debug" string describing this object - */ - inline LDK::Str debug_str(); + QueryChannelRange(const QueryChannelRange&) = delete; + QueryChannelRange(QueryChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(QueryChannelRange)); } + QueryChannelRange(LDKQueryChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryChannelRange)); } + operator LDKQueryChannelRange() && { LDKQueryChannelRange res = self; memset(&self, 0, sizeof(LDKQueryChannelRange)); return res; } + ~QueryChannelRange() { QueryChannelRange_free(self); } + QueryChannelRange& operator=(QueryChannelRange&& o) { QueryChannelRange_free(self); self = o.self; memset(&o, 0, sizeof(QueryChannelRange)); return *this; } + LDKQueryChannelRange* operator &() { return &self; } + LDKQueryChannelRange* operator ->() { return &self; } + const LDKQueryChannelRange* operator &() const { return &self; } + const LDKQueryChannelRange* operator ->() const { return &self; } }; -class PaymentError { +class ReplyChannelRange { private: - LDKPaymentError self; + LDKReplyChannelRange self; public: - PaymentError(const PaymentError&) = delete; - PaymentError(PaymentError&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentError)); } - PaymentError(LDKPaymentError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentError)); } - operator LDKPaymentError() && { LDKPaymentError res = self; memset(&self, 0, sizeof(LDKPaymentError)); return res; } - ~PaymentError() { PaymentError_free(self); } - PaymentError& operator=(PaymentError&& o) { PaymentError_free(self); self = o.self; memset(&o, 0, sizeof(PaymentError)); return *this; } - LDKPaymentError* operator &() { return &self; } - LDKPaymentError* operator ->() { return &self; } - const LDKPaymentError* operator &() const { return &self; } - const LDKPaymentError* operator ->() const { return &self; } + ReplyChannelRange(const ReplyChannelRange&) = delete; + ReplyChannelRange(ReplyChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyChannelRange)); } + ReplyChannelRange(LDKReplyChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyChannelRange)); } + operator LDKReplyChannelRange() && { LDKReplyChannelRange res = self; memset(&self, 0, sizeof(LDKReplyChannelRange)); return res; } + ~ReplyChannelRange() { ReplyChannelRange_free(self); } + ReplyChannelRange& operator=(ReplyChannelRange&& o) { ReplyChannelRange_free(self); self = o.self; memset(&o, 0, sizeof(ReplyChannelRange)); return *this; } + LDKReplyChannelRange* operator &() { return &self; } + LDKReplyChannelRange* operator ->() { return &self; } + const LDKReplyChannelRange* operator &() const { return &self; } + const LDKReplyChannelRange* operator ->() const { return &self; } }; -class ChannelMonitorUpdate { +class QueryShortChannelIds { private: - LDKChannelMonitorUpdate self; + LDKQueryShortChannelIds self; public: - ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete; - ChannelMonitorUpdate(ChannelMonitorUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdate)); } - ChannelMonitorUpdate(LDKChannelMonitorUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdate)); } - operator LDKChannelMonitorUpdate() && { LDKChannelMonitorUpdate res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdate)); return res; } - ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); } - ChannelMonitorUpdate& operator=(ChannelMonitorUpdate&& o) { ChannelMonitorUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitorUpdate)); return *this; } - LDKChannelMonitorUpdate* operator &() { return &self; } - LDKChannelMonitorUpdate* operator ->() { return &self; } - const LDKChannelMonitorUpdate* operator &() const { return &self; } - const LDKChannelMonitorUpdate* operator ->() const { return &self; } + QueryShortChannelIds(const QueryShortChannelIds&) = delete; + QueryShortChannelIds(QueryShortChannelIds&& o) : self(o.self) { memset(&o, 0, sizeof(QueryShortChannelIds)); } + QueryShortChannelIds(LDKQueryShortChannelIds&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryShortChannelIds)); } + operator LDKQueryShortChannelIds() && { LDKQueryShortChannelIds res = self; memset(&self, 0, sizeof(LDKQueryShortChannelIds)); return res; } + ~QueryShortChannelIds() { QueryShortChannelIds_free(self); } + QueryShortChannelIds& operator=(QueryShortChannelIds&& o) { QueryShortChannelIds_free(self); self = o.self; memset(&o, 0, sizeof(QueryShortChannelIds)); return *this; } + LDKQueryShortChannelIds* operator &() { return &self; } + LDKQueryShortChannelIds* operator ->() { return &self; } + const LDKQueryShortChannelIds* operator &() const { return &self; } + const LDKQueryShortChannelIds* operator ->() const { return &self; } }; -class MonitorEvent { +class ReplyShortChannelIdsEnd { private: - LDKMonitorEvent self; + LDKReplyShortChannelIdsEnd self; public: - MonitorEvent(const MonitorEvent&) = delete; - MonitorEvent(MonitorEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorEvent)); } - MonitorEvent(LDKMonitorEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorEvent)); } - operator LDKMonitorEvent() && { LDKMonitorEvent res = self; memset(&self, 0, sizeof(LDKMonitorEvent)); return res; } - ~MonitorEvent() { MonitorEvent_free(self); } - MonitorEvent& operator=(MonitorEvent&& o) { MonitorEvent_free(self); self = o.self; memset(&o, 0, sizeof(MonitorEvent)); return *this; } - LDKMonitorEvent* operator &() { return &self; } - LDKMonitorEvent* operator ->() { return &self; } - const LDKMonitorEvent* operator &() const { return &self; } - const LDKMonitorEvent* operator ->() const { return &self; } + ReplyShortChannelIdsEnd(const ReplyShortChannelIdsEnd&) = delete; + ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyShortChannelIdsEnd)); } + ReplyShortChannelIdsEnd(LDKReplyShortChannelIdsEnd&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyShortChannelIdsEnd)); } + operator LDKReplyShortChannelIdsEnd() && { LDKReplyShortChannelIdsEnd res = self; memset(&self, 0, sizeof(LDKReplyShortChannelIdsEnd)); return res; } + ~ReplyShortChannelIdsEnd() { ReplyShortChannelIdsEnd_free(self); } + ReplyShortChannelIdsEnd& operator=(ReplyShortChannelIdsEnd&& o) { ReplyShortChannelIdsEnd_free(self); self = o.self; memset(&o, 0, sizeof(ReplyShortChannelIdsEnd)); return *this; } + LDKReplyShortChannelIdsEnd* operator &() { return &self; } + LDKReplyShortChannelIdsEnd* operator ->() { return &self; } + const LDKReplyShortChannelIdsEnd* operator &() const { return &self; } + const LDKReplyShortChannelIdsEnd* operator ->() const { return &self; } }; -class HTLCUpdate { +class GossipTimestampFilter { private: - LDKHTLCUpdate self; + LDKGossipTimestampFilter self; public: - HTLCUpdate(const HTLCUpdate&) = delete; - HTLCUpdate(HTLCUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCUpdate)); } - HTLCUpdate(LDKHTLCUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCUpdate)); } - operator LDKHTLCUpdate() && { LDKHTLCUpdate res = self; memset(&self, 0, sizeof(LDKHTLCUpdate)); return res; } - ~HTLCUpdate() { HTLCUpdate_free(self); } - HTLCUpdate& operator=(HTLCUpdate&& o) { HTLCUpdate_free(self); self = o.self; memset(&o, 0, sizeof(HTLCUpdate)); return *this; } - LDKHTLCUpdate* operator &() { return &self; } - LDKHTLCUpdate* operator ->() { return &self; } - const LDKHTLCUpdate* operator &() const { return &self; } - const LDKHTLCUpdate* operator ->() const { return &self; } + GossipTimestampFilter(const GossipTimestampFilter&) = delete; + GossipTimestampFilter(GossipTimestampFilter&& o) : self(o.self) { memset(&o, 0, sizeof(GossipTimestampFilter)); } + GossipTimestampFilter(LDKGossipTimestampFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGossipTimestampFilter)); } + operator LDKGossipTimestampFilter() && { LDKGossipTimestampFilter res = self; memset(&self, 0, sizeof(LDKGossipTimestampFilter)); return res; } + ~GossipTimestampFilter() { GossipTimestampFilter_free(self); } + GossipTimestampFilter& operator=(GossipTimestampFilter&& o) { GossipTimestampFilter_free(self); self = o.self; memset(&o, 0, sizeof(GossipTimestampFilter)); return *this; } + LDKGossipTimestampFilter* operator &() { return &self; } + LDKGossipTimestampFilter* operator ->() { return &self; } + const LDKGossipTimestampFilter* operator &() const { return &self; } + const LDKGossipTimestampFilter* operator ->() const { return &self; } }; -class Balance { +class ErrorAction { private: - LDKBalance self; + LDKErrorAction self; public: - Balance(const Balance&) = delete; - Balance(Balance&& o) : self(o.self) { memset(&o, 0, sizeof(Balance)); } - Balance(LDKBalance&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBalance)); } - operator LDKBalance() && { LDKBalance res = self; memset(&self, 0, sizeof(LDKBalance)); return res; } - ~Balance() { Balance_free(self); } - Balance& operator=(Balance&& o) { Balance_free(self); self = o.self; memset(&o, 0, sizeof(Balance)); return *this; } - LDKBalance* operator &() { return &self; } - LDKBalance* operator ->() { return &self; } - const LDKBalance* operator &() const { return &self; } - const LDKBalance* operator ->() const { return &self; } + ErrorAction(const ErrorAction&) = delete; + ErrorAction(ErrorAction&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorAction)); } + ErrorAction(LDKErrorAction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorAction)); } + operator LDKErrorAction() && { LDKErrorAction res = self; memset(&self, 0, sizeof(LDKErrorAction)); return res; } + ~ErrorAction() { ErrorAction_free(self); } + ErrorAction& operator=(ErrorAction&& o) { ErrorAction_free(self); self = o.self; memset(&o, 0, sizeof(ErrorAction)); return *this; } + LDKErrorAction* operator &() { return &self; } + LDKErrorAction* operator ->() { return &self; } + const LDKErrorAction* operator &() const { return &self; } + const LDKErrorAction* operator ->() const { return &self; } }; -class ChannelMonitor { +class LightningError { private: - LDKChannelMonitor self; + LDKLightningError self; public: - ChannelMonitor(const ChannelMonitor&) = delete; - ChannelMonitor(ChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitor)); } - ChannelMonitor(LDKChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitor)); } - operator LDKChannelMonitor() && { LDKChannelMonitor res = self; memset(&self, 0, sizeof(LDKChannelMonitor)); return res; } - ~ChannelMonitor() { ChannelMonitor_free(self); } - ChannelMonitor& operator=(ChannelMonitor&& o) { ChannelMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMonitor)); return *this; } - LDKChannelMonitor* operator &() { return &self; } - LDKChannelMonitor* operator ->() { return &self; } - const LDKChannelMonitor* operator &() const { return &self; } - const LDKChannelMonitor* operator ->() const { return &self; } + LightningError(const LightningError&) = delete; + LightningError(LightningError&& o) : self(o.self) { memset(&o, 0, sizeof(LightningError)); } + LightningError(LDKLightningError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLightningError)); } + operator LDKLightningError() && { LDKLightningError res = self; memset(&self, 0, sizeof(LDKLightningError)); return res; } + ~LightningError() { LightningError_free(self); } + LightningError& operator=(LightningError&& o) { LightningError_free(self); self = o.self; memset(&o, 0, sizeof(LightningError)); return *this; } + LDKLightningError* operator &() { return &self; } + LDKLightningError* operator ->() { return &self; } + const LDKLightningError* operator &() const { return &self; } + const LDKLightningError* operator ->() const { return &self; } }; -class ExpandedKey { +class CommitmentUpdate { private: - LDKExpandedKey self; + LDKCommitmentUpdate self; public: - ExpandedKey(const ExpandedKey&) = delete; - ExpandedKey(ExpandedKey&& o) : self(o.self) { memset(&o, 0, sizeof(ExpandedKey)); } - ExpandedKey(LDKExpandedKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpandedKey)); } - operator LDKExpandedKey() && { LDKExpandedKey res = self; memset(&self, 0, sizeof(LDKExpandedKey)); return res; } - ~ExpandedKey() { ExpandedKey_free(self); } - ExpandedKey& operator=(ExpandedKey&& o) { ExpandedKey_free(self); self = o.self; memset(&o, 0, sizeof(ExpandedKey)); return *this; } - LDKExpandedKey* operator &() { return &self; } - LDKExpandedKey* operator ->() { return &self; } - const LDKExpandedKey* operator &() const { return &self; } - const LDKExpandedKey* operator ->() const { return &self; } + CommitmentUpdate(const CommitmentUpdate&) = delete; + CommitmentUpdate(CommitmentUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentUpdate)); } + CommitmentUpdate(LDKCommitmentUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentUpdate)); } + operator LDKCommitmentUpdate() && { LDKCommitmentUpdate res = self; memset(&self, 0, sizeof(LDKCommitmentUpdate)); return res; } + ~CommitmentUpdate() { CommitmentUpdate_free(self); } + CommitmentUpdate& operator=(CommitmentUpdate&& o) { CommitmentUpdate_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentUpdate)); return *this; } + LDKCommitmentUpdate* operator &() { return &self; } + LDKCommitmentUpdate* operator ->() { return &self; } + const LDKCommitmentUpdate* operator &() const { return &self; } + const LDKCommitmentUpdate* operator ->() const { return &self; } }; -class CustomMessageHandler { +class ChannelMessageHandler { private: - LDKCustomMessageHandler self; + LDKChannelMessageHandler self; public: - CustomMessageHandler(const CustomMessageHandler&) = delete; - CustomMessageHandler(CustomMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageHandler)); } - CustomMessageHandler(LDKCustomMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageHandler)); } - operator LDKCustomMessageHandler() && { LDKCustomMessageHandler res = self; memset(&self, 0, sizeof(LDKCustomMessageHandler)); return res; } - ~CustomMessageHandler() { CustomMessageHandler_free(self); } - CustomMessageHandler& operator=(CustomMessageHandler&& o) { CustomMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageHandler)); return *this; } - LDKCustomMessageHandler* operator &() { return &self; } - LDKCustomMessageHandler* operator ->() { return &self; } - const LDKCustomMessageHandler* operator &() const { return &self; } - const LDKCustomMessageHandler* operator ->() const { return &self; } + ChannelMessageHandler(const ChannelMessageHandler&) = delete; + ChannelMessageHandler(ChannelMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMessageHandler)); } + ChannelMessageHandler(LDKChannelMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMessageHandler)); } + operator LDKChannelMessageHandler() && { LDKChannelMessageHandler res = self; memset(&self, 0, sizeof(LDKChannelMessageHandler)); return res; } + ~ChannelMessageHandler() { ChannelMessageHandler_free(self); } + ChannelMessageHandler& operator=(ChannelMessageHandler&& o) { ChannelMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMessageHandler)); return *this; } + LDKChannelMessageHandler* operator &() { return &self; } + LDKChannelMessageHandler* operator ->() { return &self; } + const LDKChannelMessageHandler* operator &() const { return &self; } + const LDKChannelMessageHandler* operator ->() const { return &self; } + /** + * Handle an incoming `open_channel` message from the given peer. + */ + inline void handle_open_channel(struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg); + /** + * Handle an incoming `open_channel2` message from the given peer. + */ + inline void handle_open_channel_v2(struct LDKPublicKey their_node_id, const struct LDKOpenChannelV2 *NONNULL_PTR msg); + /** + * Handle an incoming `accept_channel` message from the given peer. + */ + inline void handle_accept_channel(struct LDKPublicKey their_node_id, const struct LDKAcceptChannel *NONNULL_PTR msg); + /** + * Handle an incoming `accept_channel2` message from the given peer. + */ + inline void handle_accept_channel_v2(struct LDKPublicKey their_node_id, const struct LDKAcceptChannelV2 *NONNULL_PTR msg); + /** + * Handle an incoming `funding_created` message from the given peer. + */ + inline void handle_funding_created(struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); + /** + * Handle an incoming `funding_signed` message from the given peer. + */ + inline void handle_funding_signed(struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); + /** + * Handle an incoming `channel_ready` message from the given peer. + */ + inline void handle_channel_ready(struct LDKPublicKey their_node_id, const struct LDKChannelReady *NONNULL_PTR msg); + /** + * Handle an incoming `shutdown` message from the given peer. + */ + inline void handle_shutdown(struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg); + /** + * Handle an incoming `closing_signed` message from the given peer. + */ + inline void handle_closing_signed(struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); + /** + * Handle an incoming `tx_add_input message` from the given peer. + */ + inline void handle_tx_add_input(struct LDKPublicKey their_node_id, const struct LDKTxAddInput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_add_output` message from the given peer. + */ + inline void handle_tx_add_output(struct LDKPublicKey their_node_id, const struct LDKTxAddOutput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_remove_input` message from the given peer. + */ + inline void handle_tx_remove_input(struct LDKPublicKey their_node_id, const struct LDKTxRemoveInput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_remove_output` message from the given peer. + */ + inline void handle_tx_remove_output(struct LDKPublicKey their_node_id, const struct LDKTxRemoveOutput *NONNULL_PTR msg); + /** + * Handle an incoming `tx_complete message` from the given peer. + */ + inline void handle_tx_complete(struct LDKPublicKey their_node_id, const struct LDKTxComplete *NONNULL_PTR msg); + /** + * Handle an incoming `tx_signatures` message from the given peer. + */ + inline void handle_tx_signatures(struct LDKPublicKey their_node_id, const struct LDKTxSignatures *NONNULL_PTR msg); + /** + * Handle an incoming `tx_init_rbf` message from the given peer. + */ + inline void handle_tx_init_rbf(struct LDKPublicKey their_node_id, const struct LDKTxInitRbf *NONNULL_PTR msg); + /** + * Handle an incoming `tx_ack_rbf` message from the given peer. + */ + inline void handle_tx_ack_rbf(struct LDKPublicKey their_node_id, const struct LDKTxAckRbf *NONNULL_PTR msg); + /** + * Handle an incoming `tx_abort message` from the given peer. + */ + inline void handle_tx_abort(struct LDKPublicKey their_node_id, const struct LDKTxAbort *NONNULL_PTR msg); + /** + * Handle an incoming `update_add_htlc` message from the given peer. + */ + inline void handle_update_add_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fulfill_htlc` message from the given peer. + */ + inline void handle_update_fulfill_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fail_htlc` message from the given peer. + */ + inline void handle_update_fail_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `update_fail_malformed_htlc` message from the given peer. + */ + inline void handle_update_fail_malformed_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); + /** + * Handle an incoming `commitment_signed` message from the given peer. + */ + inline void handle_commitment_signed(struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); + /** + * Handle an incoming `revoke_and_ack` message from the given peer. + */ + inline void handle_revoke_and_ack(struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); + /** + * Handle an incoming `update_fee` message from the given peer. + */ + inline void handle_update_fee(struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); + /** + * Handle an incoming `announcement_signatures` message from the given peer. + */ + inline void handle_announcement_signatures(struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); + /** + * Indicates a connection to the peer failed/an existing connection was lost. + */ + inline void peer_disconnected(struct LDKPublicKey their_node_id); + /** + * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s). + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** - * Handles the given message sent from `sender_node_id`, possibly producing messages for - * [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] - * to send. + * Handle an incoming `channel_reestablish` message from the given peer. */ - inline LDK::CResult_NoneLightningErrorZ handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id); + inline void handle_channel_reestablish(struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); /** - * Returns the list of pending messages that were generated by the handler, clearing the list - * in the process. Each message is paired with the node id of the intended recipient. If no - * connection to the node exists, then the message is simply not sent. + * Handle an incoming `channel_update` message from the given peer. */ - inline LDK::CVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg(); -}; -class IgnoringMessageHandler { -private: - LDKIgnoringMessageHandler self; -public: - IgnoringMessageHandler(const IgnoringMessageHandler&) = delete; - IgnoringMessageHandler(IgnoringMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(IgnoringMessageHandler)); } - IgnoringMessageHandler(LDKIgnoringMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKIgnoringMessageHandler)); } - operator LDKIgnoringMessageHandler() && { LDKIgnoringMessageHandler res = self; memset(&self, 0, sizeof(LDKIgnoringMessageHandler)); return res; } - ~IgnoringMessageHandler() { IgnoringMessageHandler_free(self); } - IgnoringMessageHandler& operator=(IgnoringMessageHandler&& o) { IgnoringMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(IgnoringMessageHandler)); return *this; } - LDKIgnoringMessageHandler* operator &() { return &self; } - LDKIgnoringMessageHandler* operator ->() { return &self; } - const LDKIgnoringMessageHandler* operator &() const { return &self; } - const LDKIgnoringMessageHandler* operator ->() const { return &self; } -}; -class ErroringMessageHandler { -private: - LDKErroringMessageHandler self; -public: - ErroringMessageHandler(const ErroringMessageHandler&) = delete; - ErroringMessageHandler(ErroringMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(ErroringMessageHandler)); } - ErroringMessageHandler(LDKErroringMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErroringMessageHandler)); } - operator LDKErroringMessageHandler() && { LDKErroringMessageHandler res = self; memset(&self, 0, sizeof(LDKErroringMessageHandler)); return res; } - ~ErroringMessageHandler() { ErroringMessageHandler_free(self); } - ErroringMessageHandler& operator=(ErroringMessageHandler&& o) { ErroringMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ErroringMessageHandler)); return *this; } - LDKErroringMessageHandler* operator &() { return &self; } - LDKErroringMessageHandler* operator ->() { return &self; } - const LDKErroringMessageHandler* operator &() const { return &self; } - const LDKErroringMessageHandler* operator ->() const { return &self; } -}; -class MessageHandler { -private: - LDKMessageHandler self; -public: - MessageHandler(const MessageHandler&) = delete; - MessageHandler(MessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(MessageHandler)); } - MessageHandler(LDKMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageHandler)); } - operator LDKMessageHandler() && { LDKMessageHandler res = self; memset(&self, 0, sizeof(LDKMessageHandler)); return res; } - ~MessageHandler() { MessageHandler_free(self); } - MessageHandler& operator=(MessageHandler&& o) { MessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(MessageHandler)); return *this; } - LDKMessageHandler* operator &() { return &self; } - LDKMessageHandler* operator ->() { return &self; } - const LDKMessageHandler* operator &() const { return &self; } - const LDKMessageHandler* operator ->() const { return &self; } + inline void handle_channel_update(struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Handle an incoming `error` message from the given peer. + */ + inline void handle_error(struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + inline LDK::NodeFeatures provided_node_features(); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); + /** + * Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports. + * + * If it's `None`, then no particular network chain hash compatibility will be enforced when + * connecting to peers. + */ + inline LDK::COption_CVec_ChainHashZZ get_genesis_hashes(); }; -class SocketDescriptor { +class RoutingMessageHandler { private: - LDKSocketDescriptor self; + LDKRoutingMessageHandler self; public: - SocketDescriptor(const SocketDescriptor&) = delete; - SocketDescriptor(SocketDescriptor&& o) : self(o.self) { memset(&o, 0, sizeof(SocketDescriptor)); } - SocketDescriptor(LDKSocketDescriptor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSocketDescriptor)); } - operator LDKSocketDescriptor() && { LDKSocketDescriptor res = self; memset(&self, 0, sizeof(LDKSocketDescriptor)); return res; } - ~SocketDescriptor() { SocketDescriptor_free(self); } - SocketDescriptor& operator=(SocketDescriptor&& o) { SocketDescriptor_free(self); self = o.self; memset(&o, 0, sizeof(SocketDescriptor)); return *this; } - LDKSocketDescriptor* operator &() { return &self; } - LDKSocketDescriptor* operator ->() { return &self; } - const LDKSocketDescriptor* operator &() const { return &self; } - const LDKSocketDescriptor* operator ->() const { return &self; } + RoutingMessageHandler(const RoutingMessageHandler&) = delete; + RoutingMessageHandler(RoutingMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingMessageHandler)); } + RoutingMessageHandler(LDKRoutingMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingMessageHandler)); } + operator LDKRoutingMessageHandler() && { LDKRoutingMessageHandler res = self; memset(&self, 0, sizeof(LDKRoutingMessageHandler)); return res; } + ~RoutingMessageHandler() { RoutingMessageHandler_free(self); } + RoutingMessageHandler& operator=(RoutingMessageHandler&& o) { RoutingMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(RoutingMessageHandler)); return *this; } + LDKRoutingMessageHandler* operator &() { return &self; } + LDKRoutingMessageHandler* operator ->() { return &self; } + const LDKRoutingMessageHandler* operator &() const { return &self; } + const LDKRoutingMessageHandler* operator ->() const { return &self; } /** - * Attempts to send some data from the given slice to the peer. - * - * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be - * called and further write attempts may occur until that time. - * - * If the returned size is smaller than `data.len()`, a - * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be - * written. Additionally, until a `send_data` event completes fully, no further - * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to - * prevent denial-of-service issues, you should not read or buffer any data from the socket - * until then. + * Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, + * `false` or returning an `Err` otherwise. + */ + inline LDK::CResult_boolLightningErrorZ handle_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); + /** + * Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` + * or returning an `Err` otherwise. + */ + inline LDK::CResult_boolLightningErrorZ handle_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); + /** + * Handle an incoming `channel_update` message, returning true if it should be forwarded on, + * `false` or returning an `Err` otherwise. + */ + inline LDK::CResult_boolLightningErrorZ handle_channel_update(const struct LDKChannelUpdate *NONNULL_PTR msg); + /** + * Gets channel announcements and updates required to dump our routing table to a remote node, + * starting at the `short_channel_id` indicated by `starting_point` and including announcements + * for a single channel. + */ + inline LDK::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement(uint64_t starting_point); + /** + * Gets a node announcement required to dump our routing table to a remote node, starting at + * the node *after* the provided pubkey and including up to one announcement immediately + * higher (as defined by `::cmp`) than `starting_point`. + * If `None` is provided for `starting_point`, we start at the first node. * - * If a [`PeerManager::read_event`] call on this descriptor had previously returned true - * (indicating that read events should be paused to prevent DoS in the send buffer), - * `resume_read` may be set indicating that read events on this descriptor should resume. A - * `resume_read` of false carries no meaning, and should not cause any action. + * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline uintptr_t send_data(struct LDKu8slice data, bool resume_read); + inline LDK::NodeAnnouncement get_next_node_announcement(struct LDKNodeId starting_point); /** - * Disconnect the socket pointed to by this SocketDescriptor. + * Called when a connection is established with a peer. This can be used to + * perform routing table synchronization using a strategy defined by the + * implementor. * - * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this - * call (doing so is a noop). + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. */ - inline void disconnect_socket(); - /** Checks if two objects are equal given this object's this_arg pointer and another object. */ - inline bool eq(const struct LDKSocketDescriptor *NONNULL_PTR other_arg); + inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); /** - * Calculate a succinct non-cryptographic hash for an object given its this_arg pointer. - * This is used, for example, for inclusion of this object in a hash map. + * Handles the reply of a query we initiated to learn about channels + * for a given range of blocks. We can expect to receive one or more + * replies to a single query. */ - inline uint64_t hash(); -}; -class PeerHandleError { -private: - LDKPeerHandleError self; -public: - PeerHandleError(const PeerHandleError&) = delete; - PeerHandleError(PeerHandleError&& o) : self(o.self) { memset(&o, 0, sizeof(PeerHandleError)); } - PeerHandleError(LDKPeerHandleError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerHandleError)); } - operator LDKPeerHandleError() && { LDKPeerHandleError res = self; memset(&self, 0, sizeof(LDKPeerHandleError)); return res; } - ~PeerHandleError() { PeerHandleError_free(self); } - PeerHandleError& operator=(PeerHandleError&& o) { PeerHandleError_free(self); self = o.self; memset(&o, 0, sizeof(PeerHandleError)); return *this; } - LDKPeerHandleError* operator &() { return &self; } - LDKPeerHandleError* operator ->() { return &self; } - const LDKPeerHandleError* operator &() const { return &self; } - const LDKPeerHandleError* operator ->() const { return &self; } -}; -class PeerManager { -private: - LDKPeerManager self; -public: - PeerManager(const PeerManager&) = delete; - PeerManager(PeerManager&& o) : self(o.self) { memset(&o, 0, sizeof(PeerManager)); } - PeerManager(LDKPeerManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerManager)); } - operator LDKPeerManager() && { LDKPeerManager res = self; memset(&self, 0, sizeof(LDKPeerManager)); return res; } - ~PeerManager() { PeerManager_free(self); } - PeerManager& operator=(PeerManager&& o) { PeerManager_free(self); self = o.self; memset(&o, 0, sizeof(PeerManager)); return *this; } - LDKPeerManager* operator &() { return &self; } - LDKPeerManager* operator ->() { return &self; } - const LDKPeerManager* operator &() const { return &self; } - const LDKPeerManager* operator ->() const { return &self; } -}; -class UtxoLookupError { -private: - LDKUtxoLookupError self; -public: - UtxoLookupError(const UtxoLookupError&) = delete; - UtxoLookupError(UtxoLookupError&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoLookupError)); } - UtxoLookupError(LDKUtxoLookupError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoLookupError)); } - operator LDKUtxoLookupError() && { LDKUtxoLookupError res = self; memset(&self, 0, sizeof(LDKUtxoLookupError)); return res; } - UtxoLookupError& operator=(UtxoLookupError&& o) { self = o.self; memset(&o, 0, sizeof(UtxoLookupError)); return *this; } - LDKUtxoLookupError* operator &() { return &self; } - LDKUtxoLookupError* operator ->() { return &self; } - const LDKUtxoLookupError* operator &() const { return &self; } - const LDKUtxoLookupError* operator ->() const { return &self; } -}; -class UtxoResult { -private: - LDKUtxoResult self; -public: - UtxoResult(const UtxoResult&) = delete; - UtxoResult(UtxoResult&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoResult)); } - UtxoResult(LDKUtxoResult&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoResult)); } - operator LDKUtxoResult() && { LDKUtxoResult res = self; memset(&self, 0, sizeof(LDKUtxoResult)); return res; } - ~UtxoResult() { UtxoResult_free(self); } - UtxoResult& operator=(UtxoResult&& o) { UtxoResult_free(self); self = o.self; memset(&o, 0, sizeof(UtxoResult)); return *this; } - LDKUtxoResult* operator &() { return &self; } - LDKUtxoResult* operator ->() { return &self; } - const LDKUtxoResult* operator &() const { return &self; } - const LDKUtxoResult* operator ->() const { return &self; } -}; -class UtxoLookup { -private: - LDKUtxoLookup self; -public: - UtxoLookup(const UtxoLookup&) = delete; - UtxoLookup(UtxoLookup&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoLookup)); } - UtxoLookup(LDKUtxoLookup&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoLookup)); } - operator LDKUtxoLookup() && { LDKUtxoLookup res = self; memset(&self, 0, sizeof(LDKUtxoLookup)); return res; } - ~UtxoLookup() { UtxoLookup_free(self); } - UtxoLookup& operator=(UtxoLookup&& o) { UtxoLookup_free(self); self = o.self; memset(&o, 0, sizeof(UtxoLookup)); return *this; } - LDKUtxoLookup* operator &() { return &self; } - LDKUtxoLookup* operator ->() { return &self; } - const LDKUtxoLookup* operator &() const { return &self; } - const LDKUtxoLookup* operator ->() const { return &self; } + inline LDK::CResult_NoneLightningErrorZ handle_reply_channel_range(struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); + /** + * Handles the reply of a query we initiated asking for routing gossip + * messages for a list of channels. We should receive this message when + * a node has completed its best effort to send us the pertaining routing + * gossip messages. + */ + inline LDK::CResult_NoneLightningErrorZ handle_reply_short_channel_ids_end(struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); + /** + * Handles when a peer asks us to send a list of `short_channel_id`s + * for the requested range of blocks. + */ + inline LDK::CResult_NoneLightningErrorZ handle_query_channel_range(struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); /** - * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. - * Returns an error if `genesis_hash` is for a different chain or if such a transaction output - * is unknown. + * Handles when a peer asks us to send routing gossip messages for a + * list of `short_channel_id`s. + */ + inline LDK::CResult_NoneLightningErrorZ handle_query_short_channel_ids(struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); + /** + * Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages + * pending some async action. While there is no guarantee of the rate of future messages, the + * caller should seek to reduce the rate of new gossip messages handled, especially + * [`ChannelAnnouncement`]s. + */ + inline bool processing_queue_high(); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + inline LDK::NodeFeatures provided_node_features(); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. * - * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id + * Note that this method is called before [`Self::peer_connected`]. */ - inline LDK::UtxoResult get_utxo(const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); -}; -class UtxoFuture { -private: - LDKUtxoFuture self; -public: - UtxoFuture(const UtxoFuture&) = delete; - UtxoFuture(UtxoFuture&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoFuture)); } - UtxoFuture(LDKUtxoFuture&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoFuture)); } - operator LDKUtxoFuture() && { LDKUtxoFuture res = self; memset(&self, 0, sizeof(LDKUtxoFuture)); return res; } - ~UtxoFuture() { UtxoFuture_free(self); } - UtxoFuture& operator=(UtxoFuture&& o) { UtxoFuture_free(self); self = o.self; memset(&o, 0, sizeof(UtxoFuture)); return *this; } - LDKUtxoFuture* operator &() { return &self; } - LDKUtxoFuture* operator ->() { return &self; } - const LDKUtxoFuture* operator &() const { return &self; } - const LDKUtxoFuture* operator ->() const { return &self; } + inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); }; -class OnionMessenger { +class OnionMessageHandler { private: - LDKOnionMessenger self; + LDKOnionMessageHandler self; public: - OnionMessenger(const OnionMessenger&) = delete; - OnionMessenger(OnionMessenger&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessenger)); } - OnionMessenger(LDKOnionMessenger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessenger)); } - operator LDKOnionMessenger() && { LDKOnionMessenger res = self; memset(&self, 0, sizeof(LDKOnionMessenger)); return res; } - ~OnionMessenger() { OnionMessenger_free(self); } - OnionMessenger& operator=(OnionMessenger&& o) { OnionMessenger_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessenger)); return *this; } - LDKOnionMessenger* operator &() { return &self; } - LDKOnionMessenger* operator ->() { return &self; } - const LDKOnionMessenger* operator &() const { return &self; } - const LDKOnionMessenger* operator ->() const { return &self; } + OnionMessageHandler(const OnionMessageHandler&) = delete; + OnionMessageHandler(OnionMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageHandler)); } + OnionMessageHandler(LDKOnionMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageHandler)); } + operator LDKOnionMessageHandler() && { LDKOnionMessageHandler res = self; memset(&self, 0, sizeof(LDKOnionMessageHandler)); return res; } + ~OnionMessageHandler() { OnionMessageHandler_free(self); } + OnionMessageHandler& operator=(OnionMessageHandler&& o) { OnionMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageHandler)); return *this; } + LDKOnionMessageHandler* operator &() { return &self; } + LDKOnionMessageHandler* operator ->() { return &self; } + const LDKOnionMessageHandler* operator &() const { return &self; } + const LDKOnionMessageHandler* operator ->() const { return &self; } + /** + * Handle an incoming `onion_message` message from the given peer. + */ + inline void handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg); + /** + * Called when a connection is established with a peer. Can be used to track which peers + * advertise onion message support and are online. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + /** + * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to + * drop and refuse to forward onion messages to this peer. + */ + inline void peer_disconnected(struct LDKPublicKey their_node_id); + /** + * Gets the node feature flags which this handler itself supports. All available handlers are + * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + * which are broadcasted in our [`NodeAnnouncement`] message. + */ + inline LDK::NodeFeatures provided_node_features(); + /** + * Gets the init feature flags which should be sent to the given peer. All available handlers + * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + * which are sent in our [`Init`] message. + * + * Note that this method is called before [`Self::peer_connected`]. + */ + inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); }; -class Destination { +class Level { private: - LDKDestination self; + LDKLevel self; public: - Destination(const Destination&) = delete; - Destination(Destination&& o) : self(o.self) { memset(&o, 0, sizeof(Destination)); } - Destination(LDKDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDestination)); } - operator LDKDestination() && { LDKDestination res = self; memset(&self, 0, sizeof(LDKDestination)); return res; } - ~Destination() { Destination_free(self); } - Destination& operator=(Destination&& o) { Destination_free(self); self = o.self; memset(&o, 0, sizeof(Destination)); return *this; } - LDKDestination* operator &() { return &self; } - LDKDestination* operator ->() { return &self; } - const LDKDestination* operator &() const { return &self; } - const LDKDestination* operator ->() const { return &self; } + Level(const Level&) = delete; + Level(Level&& o) : self(o.self) { memset(&o, 0, sizeof(Level)); } + Level(LDKLevel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLevel)); } + operator LDKLevel() && { LDKLevel res = self; memset(&self, 0, sizeof(LDKLevel)); return res; } + Level& operator=(Level&& o) { self = o.self; memset(&o, 0, sizeof(Level)); return *this; } + LDKLevel* operator &() { return &self; } + LDKLevel* operator ->() { return &self; } + const LDKLevel* operator &() const { return &self; } + const LDKLevel* operator ->() const { return &self; } }; -class SendError { +class Record { private: - LDKSendError self; + LDKRecord self; public: - SendError(const SendError&) = delete; - SendError(SendError&& o) : self(o.self) { memset(&o, 0, sizeof(SendError)); } - SendError(LDKSendError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSendError)); } - operator LDKSendError() && { LDKSendError res = self; memset(&self, 0, sizeof(LDKSendError)); return res; } - ~SendError() { SendError_free(self); } - SendError& operator=(SendError&& o) { SendError_free(self); self = o.self; memset(&o, 0, sizeof(SendError)); return *this; } - LDKSendError* operator &() { return &self; } - LDKSendError* operator ->() { return &self; } - const LDKSendError* operator &() const { return &self; } - const LDKSendError* operator ->() const { return &self; } + Record(const Record&) = delete; + Record(Record&& o) : self(o.self) { memset(&o, 0, sizeof(Record)); } + Record(LDKRecord&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecord)); } + operator LDKRecord() && { LDKRecord res = self; memset(&self, 0, sizeof(LDKRecord)); return res; } + ~Record() { Record_free(self); } + Record& operator=(Record&& o) { Record_free(self); self = o.self; memset(&o, 0, sizeof(Record)); return *this; } + LDKRecord* operator &() { return &self; } + LDKRecord* operator ->() { return &self; } + const LDKRecord* operator &() const { return &self; } + const LDKRecord* operator ->() const { return &self; } }; -class CustomOnionMessageHandler { +class Logger { private: - LDKCustomOnionMessageHandler self; + LDKLogger self; public: - CustomOnionMessageHandler(const CustomOnionMessageHandler&) = delete; - CustomOnionMessageHandler(CustomOnionMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageHandler)); } - CustomOnionMessageHandler(LDKCustomOnionMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageHandler)); } - operator LDKCustomOnionMessageHandler() && { LDKCustomOnionMessageHandler res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageHandler)); return res; } - ~CustomOnionMessageHandler() { CustomOnionMessageHandler_free(self); } - CustomOnionMessageHandler& operator=(CustomOnionMessageHandler&& o) { CustomOnionMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageHandler)); return *this; } - LDKCustomOnionMessageHandler* operator &() { return &self; } - LDKCustomOnionMessageHandler* operator ->() { return &self; } - const LDKCustomOnionMessageHandler* operator &() const { return &self; } - const LDKCustomOnionMessageHandler* operator ->() const { return &self; } - /** - * Called with the custom message that was received. - */ - inline void handle_custom_message(struct LDKCustomOnionMessageContents msg); + Logger(const Logger&) = delete; + Logger(Logger&& o) : self(o.self) { memset(&o, 0, sizeof(Logger)); } + Logger(LDKLogger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLogger)); } + operator LDKLogger() && { LDKLogger res = self; memset(&self, 0, sizeof(LDKLogger)); return res; } + ~Logger() { Logger_free(self); } + Logger& operator=(Logger&& o) { Logger_free(self); self = o.self; memset(&o, 0, sizeof(Logger)); return *this; } + LDKLogger* operator &() { return &self; } + LDKLogger* operator ->() { return &self; } + const LDKLogger* operator &() const { return &self; } + const LDKLogger* operator ->() const { return &self; } /** - * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the - * message type is unknown. + * Logs the `Record` */ - inline LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message(uint64_t message_type, struct LDKu8slice buffer); -}; -class BlindedPath { -private: - LDKBlindedPath self; -public: - BlindedPath(const BlindedPath&) = delete; - BlindedPath(BlindedPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPath)); } - BlindedPath(LDKBlindedPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPath)); } - operator LDKBlindedPath() && { LDKBlindedPath res = self; memset(&self, 0, sizeof(LDKBlindedPath)); return res; } - ~BlindedPath() { BlindedPath_free(self); } - BlindedPath& operator=(BlindedPath&& o) { BlindedPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPath)); return *this; } - LDKBlindedPath* operator &() { return &self; } - LDKBlindedPath* operator ->() { return &self; } - const LDKBlindedPath* operator &() const { return &self; } - const LDKBlindedPath* operator ->() const { return &self; } + inline void log(const struct LDKRecord *NONNULL_PTR record); }; -class BlindedHop { +class FutureCallback { private: - LDKBlindedHop self; + LDKFutureCallback self; public: - BlindedHop(const BlindedHop&) = delete; - BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } - BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } - operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } - ~BlindedHop() { BlindedHop_free(self); } - BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } - LDKBlindedHop* operator &() { return &self; } - LDKBlindedHop* operator ->() { return &self; } - const LDKBlindedHop* operator &() const { return &self; } - const LDKBlindedHop* operator ->() const { return &self; } + FutureCallback(const FutureCallback&) = delete; + FutureCallback(FutureCallback&& o) : self(o.self) { memset(&o, 0, sizeof(FutureCallback)); } + FutureCallback(LDKFutureCallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFutureCallback)); } + operator LDKFutureCallback() && { LDKFutureCallback res = self; memset(&self, 0, sizeof(LDKFutureCallback)); return res; } + ~FutureCallback() { FutureCallback_free(self); } + FutureCallback& operator=(FutureCallback&& o) { FutureCallback_free(self); self = o.self; memset(&o, 0, sizeof(FutureCallback)); return *this; } + LDKFutureCallback* operator &() { return &self; } + LDKFutureCallback* operator ->() { return &self; } + const LDKFutureCallback* operator &() const { return &self; } + const LDKFutureCallback* operator ->() const { return &self; } + /** + * The method which is called. + */ + inline void call(); }; -class ParseError { +class Future { private: - LDKParseError self; + LDKFuture self; public: - ParseError(const ParseError&) = delete; - ParseError(ParseError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseError)); } - ParseError(LDKParseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseError)); } - operator LDKParseError() && { LDKParseError res = self; memset(&self, 0, sizeof(LDKParseError)); return res; } - ~ParseError() { ParseError_free(self); } - ParseError& operator=(ParseError&& o) { ParseError_free(self); self = o.self; memset(&o, 0, sizeof(ParseError)); return *this; } - LDKParseError* operator &() { return &self; } - LDKParseError* operator ->() { return &self; } - const LDKParseError* operator &() const { return &self; } - const LDKParseError* operator ->() const { return &self; } + Future(const Future&) = delete; + Future(Future&& o) : self(o.self) { memset(&o, 0, sizeof(Future)); } + Future(LDKFuture&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFuture)); } + operator LDKFuture() && { LDKFuture res = self; memset(&self, 0, sizeof(LDKFuture)); return res; } + ~Future() { Future_free(self); } + Future& operator=(Future&& o) { Future_free(self); self = o.self; memset(&o, 0, sizeof(Future)); return *this; } + LDKFuture* operator &() { return &self; } + LDKFuture* operator ->() { return &self; } + const LDKFuture* operator &() const { return &self; } + const LDKFuture* operator ->() const { return &self; } }; -class ParseOrSemanticError { +class Sleeper { private: - LDKParseOrSemanticError self; + LDKSleeper self; public: - ParseOrSemanticError(const ParseOrSemanticError&) = delete; - ParseOrSemanticError(ParseOrSemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseOrSemanticError)); } - ParseOrSemanticError(LDKParseOrSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseOrSemanticError)); } - operator LDKParseOrSemanticError() && { LDKParseOrSemanticError res = self; memset(&self, 0, sizeof(LDKParseOrSemanticError)); return res; } - ~ParseOrSemanticError() { ParseOrSemanticError_free(self); } - ParseOrSemanticError& operator=(ParseOrSemanticError&& o) { ParseOrSemanticError_free(self); self = o.self; memset(&o, 0, sizeof(ParseOrSemanticError)); return *this; } - LDKParseOrSemanticError* operator &() { return &self; } - LDKParseOrSemanticError* operator ->() { return &self; } - const LDKParseOrSemanticError* operator &() const { return &self; } - const LDKParseOrSemanticError* operator ->() const { return &self; } -}; -class Invoice { -private: - LDKInvoice self; -public: - Invoice(const Invoice&) = delete; - Invoice(Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Invoice)); } - Invoice(LDKInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoice)); } - operator LDKInvoice() && { LDKInvoice res = self; memset(&self, 0, sizeof(LDKInvoice)); return res; } - ~Invoice() { Invoice_free(self); } - Invoice& operator=(Invoice&& o) { Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Invoice)); return *this; } - LDKInvoice* operator &() { return &self; } - LDKInvoice* operator ->() { return &self; } - const LDKInvoice* operator &() const { return &self; } - const LDKInvoice* operator ->() const { return &self; } -}; -class SignedRawInvoice { -private: - LDKSignedRawInvoice self; -public: - SignedRawInvoice(const SignedRawInvoice&) = delete; - SignedRawInvoice(SignedRawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(SignedRawInvoice)); } - SignedRawInvoice(LDKSignedRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignedRawInvoice)); } - operator LDKSignedRawInvoice() && { LDKSignedRawInvoice res = self; memset(&self, 0, sizeof(LDKSignedRawInvoice)); return res; } - ~SignedRawInvoice() { SignedRawInvoice_free(self); } - SignedRawInvoice& operator=(SignedRawInvoice&& o) { SignedRawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(SignedRawInvoice)); return *this; } - LDKSignedRawInvoice* operator &() { return &self; } - LDKSignedRawInvoice* operator ->() { return &self; } - const LDKSignedRawInvoice* operator &() const { return &self; } - const LDKSignedRawInvoice* operator ->() const { return &self; } -}; -class RawInvoice { -private: - LDKRawInvoice self; -public: - RawInvoice(const RawInvoice&) = delete; - RawInvoice(RawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(RawInvoice)); } - RawInvoice(LDKRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawInvoice)); } - operator LDKRawInvoice() && { LDKRawInvoice res = self; memset(&self, 0, sizeof(LDKRawInvoice)); return res; } - ~RawInvoice() { RawInvoice_free(self); } - RawInvoice& operator=(RawInvoice&& o) { RawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(RawInvoice)); return *this; } - LDKRawInvoice* operator &() { return &self; } - LDKRawInvoice* operator ->() { return &self; } - const LDKRawInvoice* operator &() const { return &self; } - const LDKRawInvoice* operator ->() const { return &self; } + Sleeper(const Sleeper&) = delete; + Sleeper(Sleeper&& o) : self(o.self) { memset(&o, 0, sizeof(Sleeper)); } + Sleeper(LDKSleeper&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSleeper)); } + operator LDKSleeper() && { LDKSleeper res = self; memset(&self, 0, sizeof(LDKSleeper)); return res; } + ~Sleeper() { Sleeper_free(self); } + Sleeper& operator=(Sleeper&& o) { Sleeper_free(self); self = o.self; memset(&o, 0, sizeof(Sleeper)); return *this; } + LDKSleeper* operator &() { return &self; } + LDKSleeper* operator ->() { return &self; } + const LDKSleeper* operator &() const { return &self; } + const LDKSleeper* operator ->() const { return &self; } }; -class RawDataPart { +class OffersMessageHandler { private: - LDKRawDataPart self; + LDKOffersMessageHandler self; public: - RawDataPart(const RawDataPart&) = delete; - RawDataPart(RawDataPart&& o) : self(o.self) { memset(&o, 0, sizeof(RawDataPart)); } - RawDataPart(LDKRawDataPart&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawDataPart)); } - operator LDKRawDataPart() && { LDKRawDataPart res = self; memset(&self, 0, sizeof(LDKRawDataPart)); return res; } - ~RawDataPart() { RawDataPart_free(self); } - RawDataPart& operator=(RawDataPart&& o) { RawDataPart_free(self); self = o.self; memset(&o, 0, sizeof(RawDataPart)); return *this; } - LDKRawDataPart* operator &() { return &self; } - LDKRawDataPart* operator ->() { return &self; } - const LDKRawDataPart* operator &() const { return &self; } - const LDKRawDataPart* operator ->() const { return &self; } + OffersMessageHandler(const OffersMessageHandler&) = delete; + OffersMessageHandler(OffersMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(OffersMessageHandler)); } + OffersMessageHandler(LDKOffersMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffersMessageHandler)); } + operator LDKOffersMessageHandler() && { LDKOffersMessageHandler res = self; memset(&self, 0, sizeof(LDKOffersMessageHandler)); return res; } + ~OffersMessageHandler() { OffersMessageHandler_free(self); } + OffersMessageHandler& operator=(OffersMessageHandler&& o) { OffersMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(OffersMessageHandler)); return *this; } + LDKOffersMessageHandler* operator &() { return &self; } + LDKOffersMessageHandler* operator ->() { return &self; } + const LDKOffersMessageHandler* operator &() const { return &self; } + const LDKOffersMessageHandler* operator ->() const { return &self; } + /** + * Handles the given message by either responding with an [`Bolt12Invoice`], sending a payment, + * or replying with an error. + */ + inline LDK::COption_OffersMessageZ handle_message(struct LDKOffersMessage message); }; -class PositiveTimestamp { +class OffersMessage { private: - LDKPositiveTimestamp self; + LDKOffersMessage self; public: - PositiveTimestamp(const PositiveTimestamp&) = delete; - PositiveTimestamp(PositiveTimestamp&& o) : self(o.self) { memset(&o, 0, sizeof(PositiveTimestamp)); } - PositiveTimestamp(LDKPositiveTimestamp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPositiveTimestamp)); } - operator LDKPositiveTimestamp() && { LDKPositiveTimestamp res = self; memset(&self, 0, sizeof(LDKPositiveTimestamp)); return res; } - ~PositiveTimestamp() { PositiveTimestamp_free(self); } - PositiveTimestamp& operator=(PositiveTimestamp&& o) { PositiveTimestamp_free(self); self = o.self; memset(&o, 0, sizeof(PositiveTimestamp)); return *this; } - LDKPositiveTimestamp* operator &() { return &self; } - LDKPositiveTimestamp* operator ->() { return &self; } - const LDKPositiveTimestamp* operator &() const { return &self; } - const LDKPositiveTimestamp* operator ->() const { return &self; } + OffersMessage(const OffersMessage&) = delete; + OffersMessage(OffersMessage&& o) : self(o.self) { memset(&o, 0, sizeof(OffersMessage)); } + OffersMessage(LDKOffersMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffersMessage)); } + operator LDKOffersMessage() && { LDKOffersMessage res = self; memset(&self, 0, sizeof(LDKOffersMessage)); return res; } + ~OffersMessage() { OffersMessage_free(self); } + OffersMessage& operator=(OffersMessage&& o) { OffersMessage_free(self); self = o.self; memset(&o, 0, sizeof(OffersMessage)); return *this; } + LDKOffersMessage* operator &() { return &self; } + LDKOffersMessage* operator ->() { return &self; } + const LDKOffersMessage* operator &() const { return &self; } + const LDKOffersMessage* operator ->() const { return &self; } }; -class SiPrefix { +class HTLCClaim { private: - LDKSiPrefix self; + LDKHTLCClaim self; public: - SiPrefix(const SiPrefix&) = delete; - SiPrefix(SiPrefix&& o) : self(o.self) { memset(&o, 0, sizeof(SiPrefix)); } - SiPrefix(LDKSiPrefix&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSiPrefix)); } - operator LDKSiPrefix() && { LDKSiPrefix res = self; memset(&self, 0, sizeof(LDKSiPrefix)); return res; } - SiPrefix& operator=(SiPrefix&& o) { self = o.self; memset(&o, 0, sizeof(SiPrefix)); return *this; } - LDKSiPrefix* operator &() { return &self; } - LDKSiPrefix* operator ->() { return &self; } - const LDKSiPrefix* operator &() const { return &self; } - const LDKSiPrefix* operator ->() const { return &self; } + HTLCClaim(const HTLCClaim&) = delete; + HTLCClaim(HTLCClaim&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCClaim)); } + HTLCClaim(LDKHTLCClaim&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCClaim)); } + operator LDKHTLCClaim() && { LDKHTLCClaim res = self; memset(&self, 0, sizeof(LDKHTLCClaim)); return res; } + HTLCClaim& operator=(HTLCClaim&& o) { self = o.self; memset(&o, 0, sizeof(HTLCClaim)); return *this; } + LDKHTLCClaim* operator &() { return &self; } + LDKHTLCClaim* operator ->() { return &self; } + const LDKHTLCClaim* operator &() const { return &self; } + const LDKHTLCClaim* operator ->() const { return &self; } }; -class Currency { +class CounterpartyCommitmentSecrets { private: - LDKCurrency self; + LDKCounterpartyCommitmentSecrets self; public: - Currency(const Currency&) = delete; - Currency(Currency&& o) : self(o.self) { memset(&o, 0, sizeof(Currency)); } - Currency(LDKCurrency&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCurrency)); } - operator LDKCurrency() && { LDKCurrency res = self; memset(&self, 0, sizeof(LDKCurrency)); return res; } - Currency& operator=(Currency&& o) { self = o.self; memset(&o, 0, sizeof(Currency)); return *this; } - LDKCurrency* operator &() { return &self; } - LDKCurrency* operator ->() { return &self; } - const LDKCurrency* operator &() const { return &self; } - const LDKCurrency* operator ->() const { return &self; } + CounterpartyCommitmentSecrets(const CounterpartyCommitmentSecrets&) = delete; + CounterpartyCommitmentSecrets(CounterpartyCommitmentSecrets&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); } + CounterpartyCommitmentSecrets(LDKCounterpartyCommitmentSecrets&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); } + operator LDKCounterpartyCommitmentSecrets() && { LDKCounterpartyCommitmentSecrets res = self; memset(&self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); return res; } + ~CounterpartyCommitmentSecrets() { CounterpartyCommitmentSecrets_free(self); } + CounterpartyCommitmentSecrets& operator=(CounterpartyCommitmentSecrets&& o) { CounterpartyCommitmentSecrets_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); return *this; } + LDKCounterpartyCommitmentSecrets* operator &() { return &self; } + LDKCounterpartyCommitmentSecrets* operator ->() { return &self; } + const LDKCounterpartyCommitmentSecrets* operator &() const { return &self; } + const LDKCounterpartyCommitmentSecrets* operator ->() const { return &self; } }; -class Sha256 { +class TxCreationKeys { private: - LDKSha256 self; + LDKTxCreationKeys self; public: - Sha256(const Sha256&) = delete; - Sha256(Sha256&& o) : self(o.self) { memset(&o, 0, sizeof(Sha256)); } - Sha256(LDKSha256&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSha256)); } - operator LDKSha256() && { LDKSha256 res = self; memset(&self, 0, sizeof(LDKSha256)); return res; } - ~Sha256() { Sha256_free(self); } - Sha256& operator=(Sha256&& o) { Sha256_free(self); self = o.self; memset(&o, 0, sizeof(Sha256)); return *this; } - LDKSha256* operator &() { return &self; } - LDKSha256* operator ->() { return &self; } - const LDKSha256* operator &() const { return &self; } - const LDKSha256* operator ->() const { return &self; } + TxCreationKeys(const TxCreationKeys&) = delete; + TxCreationKeys(TxCreationKeys&& o) : self(o.self) { memset(&o, 0, sizeof(TxCreationKeys)); } + TxCreationKeys(LDKTxCreationKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTxCreationKeys)); } + operator LDKTxCreationKeys() && { LDKTxCreationKeys res = self; memset(&self, 0, sizeof(LDKTxCreationKeys)); return res; } + ~TxCreationKeys() { TxCreationKeys_free(self); } + TxCreationKeys& operator=(TxCreationKeys&& o) { TxCreationKeys_free(self); self = o.self; memset(&o, 0, sizeof(TxCreationKeys)); return *this; } + LDKTxCreationKeys* operator &() { return &self; } + LDKTxCreationKeys* operator ->() { return &self; } + const LDKTxCreationKeys* operator &() const { return &self; } + const LDKTxCreationKeys* operator ->() const { return &self; } }; -class Description { +class ChannelPublicKeys { private: - LDKDescription self; + LDKChannelPublicKeys self; public: - Description(const Description&) = delete; - Description(Description&& o) : self(o.self) { memset(&o, 0, sizeof(Description)); } - Description(LDKDescription&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDescription)); } - operator LDKDescription() && { LDKDescription res = self; memset(&self, 0, sizeof(LDKDescription)); return res; } - ~Description() { Description_free(self); } - Description& operator=(Description&& o) { Description_free(self); self = o.self; memset(&o, 0, sizeof(Description)); return *this; } - LDKDescription* operator &() { return &self; } - LDKDescription* operator ->() { return &self; } - const LDKDescription* operator &() const { return &self; } - const LDKDescription* operator ->() const { return &self; } + ChannelPublicKeys(const ChannelPublicKeys&) = delete; + ChannelPublicKeys(ChannelPublicKeys&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelPublicKeys)); } + ChannelPublicKeys(LDKChannelPublicKeys&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelPublicKeys)); } + operator LDKChannelPublicKeys() && { LDKChannelPublicKeys res = self; memset(&self, 0, sizeof(LDKChannelPublicKeys)); return res; } + ~ChannelPublicKeys() { ChannelPublicKeys_free(self); } + ChannelPublicKeys& operator=(ChannelPublicKeys&& o) { ChannelPublicKeys_free(self); self = o.self; memset(&o, 0, sizeof(ChannelPublicKeys)); return *this; } + LDKChannelPublicKeys* operator &() { return &self; } + LDKChannelPublicKeys* operator ->() { return &self; } + const LDKChannelPublicKeys* operator &() const { return &self; } + const LDKChannelPublicKeys* operator ->() const { return &self; } }; -class PayeePubKey { +class HTLCOutputInCommitment { private: - LDKPayeePubKey self; + LDKHTLCOutputInCommitment self; public: - PayeePubKey(const PayeePubKey&) = delete; - PayeePubKey(PayeePubKey&& o) : self(o.self) { memset(&o, 0, sizeof(PayeePubKey)); } - PayeePubKey(LDKPayeePubKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayeePubKey)); } - operator LDKPayeePubKey() && { LDKPayeePubKey res = self; memset(&self, 0, sizeof(LDKPayeePubKey)); return res; } - ~PayeePubKey() { PayeePubKey_free(self); } - PayeePubKey& operator=(PayeePubKey&& o) { PayeePubKey_free(self); self = o.self; memset(&o, 0, sizeof(PayeePubKey)); return *this; } - LDKPayeePubKey* operator &() { return &self; } - LDKPayeePubKey* operator ->() { return &self; } - const LDKPayeePubKey* operator &() const { return &self; } - const LDKPayeePubKey* operator ->() const { return &self; } + HTLCOutputInCommitment(const HTLCOutputInCommitment&) = delete; + HTLCOutputInCommitment(HTLCOutputInCommitment&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCOutputInCommitment)); } + HTLCOutputInCommitment(LDKHTLCOutputInCommitment&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCOutputInCommitment)); } + operator LDKHTLCOutputInCommitment() && { LDKHTLCOutputInCommitment res = self; memset(&self, 0, sizeof(LDKHTLCOutputInCommitment)); return res; } + ~HTLCOutputInCommitment() { HTLCOutputInCommitment_free(self); } + HTLCOutputInCommitment& operator=(HTLCOutputInCommitment&& o) { HTLCOutputInCommitment_free(self); self = o.self; memset(&o, 0, sizeof(HTLCOutputInCommitment)); return *this; } + LDKHTLCOutputInCommitment* operator &() { return &self; } + LDKHTLCOutputInCommitment* operator ->() { return &self; } + const LDKHTLCOutputInCommitment* operator &() const { return &self; } + const LDKHTLCOutputInCommitment* operator ->() const { return &self; } }; -class ExpiryTime { +class ChannelTransactionParameters { private: - LDKExpiryTime self; + LDKChannelTransactionParameters self; public: - ExpiryTime(const ExpiryTime&) = delete; - ExpiryTime(ExpiryTime&& o) : self(o.self) { memset(&o, 0, sizeof(ExpiryTime)); } - ExpiryTime(LDKExpiryTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpiryTime)); } - operator LDKExpiryTime() && { LDKExpiryTime res = self; memset(&self, 0, sizeof(LDKExpiryTime)); return res; } - ~ExpiryTime() { ExpiryTime_free(self); } - ExpiryTime& operator=(ExpiryTime&& o) { ExpiryTime_free(self); self = o.self; memset(&o, 0, sizeof(ExpiryTime)); return *this; } - LDKExpiryTime* operator &() { return &self; } - LDKExpiryTime* operator ->() { return &self; } - const LDKExpiryTime* operator &() const { return &self; } - const LDKExpiryTime* operator ->() const { return &self; } + ChannelTransactionParameters(const ChannelTransactionParameters&) = delete; + ChannelTransactionParameters(ChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTransactionParameters)); } + ChannelTransactionParameters(LDKChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTransactionParameters)); } + operator LDKChannelTransactionParameters() && { LDKChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKChannelTransactionParameters)); return res; } + ~ChannelTransactionParameters() { ChannelTransactionParameters_free(self); } + ChannelTransactionParameters& operator=(ChannelTransactionParameters&& o) { ChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTransactionParameters)); return *this; } + LDKChannelTransactionParameters* operator &() { return &self; } + LDKChannelTransactionParameters* operator ->() { return &self; } + const LDKChannelTransactionParameters* operator &() const { return &self; } + const LDKChannelTransactionParameters* operator ->() const { return &self; } }; -class MinFinalCltvExpiryDelta { +class CounterpartyChannelTransactionParameters { private: - LDKMinFinalCltvExpiryDelta self; + LDKCounterpartyChannelTransactionParameters self; public: - MinFinalCltvExpiryDelta(const MinFinalCltvExpiryDelta&) = delete; - MinFinalCltvExpiryDelta(MinFinalCltvExpiryDelta&& o) : self(o.self) { memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); } - MinFinalCltvExpiryDelta(LDKMinFinalCltvExpiryDelta&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); } - operator LDKMinFinalCltvExpiryDelta() && { LDKMinFinalCltvExpiryDelta res = self; memset(&self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); return res; } - ~MinFinalCltvExpiryDelta() { MinFinalCltvExpiryDelta_free(self); } - MinFinalCltvExpiryDelta& operator=(MinFinalCltvExpiryDelta&& o) { MinFinalCltvExpiryDelta_free(self); self = o.self; memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); return *this; } - LDKMinFinalCltvExpiryDelta* operator &() { return &self; } - LDKMinFinalCltvExpiryDelta* operator ->() { return &self; } - const LDKMinFinalCltvExpiryDelta* operator &() const { return &self; } - const LDKMinFinalCltvExpiryDelta* operator ->() const { return &self; } + CounterpartyChannelTransactionParameters(const CounterpartyChannelTransactionParameters&) = delete; + CounterpartyChannelTransactionParameters(CounterpartyChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyChannelTransactionParameters)); } + CounterpartyChannelTransactionParameters(LDKCounterpartyChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); } + operator LDKCounterpartyChannelTransactionParameters() && { LDKCounterpartyChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKCounterpartyChannelTransactionParameters)); return res; } + ~CounterpartyChannelTransactionParameters() { CounterpartyChannelTransactionParameters_free(self); } + CounterpartyChannelTransactionParameters& operator=(CounterpartyChannelTransactionParameters&& o) { CounterpartyChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyChannelTransactionParameters)); return *this; } + LDKCounterpartyChannelTransactionParameters* operator &() { return &self; } + LDKCounterpartyChannelTransactionParameters* operator ->() { return &self; } + const LDKCounterpartyChannelTransactionParameters* operator &() const { return &self; } + const LDKCounterpartyChannelTransactionParameters* operator ->() const { return &self; } }; -class Fallback { +class DirectedChannelTransactionParameters { private: - LDKFallback self; + LDKDirectedChannelTransactionParameters self; public: - Fallback(const Fallback&) = delete; - Fallback(Fallback&& o) : self(o.self) { memset(&o, 0, sizeof(Fallback)); } - Fallback(LDKFallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFallback)); } - operator LDKFallback() && { LDKFallback res = self; memset(&self, 0, sizeof(LDKFallback)); return res; } - ~Fallback() { Fallback_free(self); } - Fallback& operator=(Fallback&& o) { Fallback_free(self); self = o.self; memset(&o, 0, sizeof(Fallback)); return *this; } - LDKFallback* operator &() { return &self; } - LDKFallback* operator ->() { return &self; } - const LDKFallback* operator &() const { return &self; } - const LDKFallback* operator ->() const { return &self; } + DirectedChannelTransactionParameters(const DirectedChannelTransactionParameters&) = delete; + DirectedChannelTransactionParameters(DirectedChannelTransactionParameters&& o) : self(o.self) { memset(&o, 0, sizeof(DirectedChannelTransactionParameters)); } + DirectedChannelTransactionParameters(LDKDirectedChannelTransactionParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectedChannelTransactionParameters)); } + operator LDKDirectedChannelTransactionParameters() && { LDKDirectedChannelTransactionParameters res = self; memset(&self, 0, sizeof(LDKDirectedChannelTransactionParameters)); return res; } + ~DirectedChannelTransactionParameters() { DirectedChannelTransactionParameters_free(self); } + DirectedChannelTransactionParameters& operator=(DirectedChannelTransactionParameters&& o) { DirectedChannelTransactionParameters_free(self); self = o.self; memset(&o, 0, sizeof(DirectedChannelTransactionParameters)); return *this; } + LDKDirectedChannelTransactionParameters* operator &() { return &self; } + LDKDirectedChannelTransactionParameters* operator ->() { return &self; } + const LDKDirectedChannelTransactionParameters* operator &() const { return &self; } + const LDKDirectedChannelTransactionParameters* operator ->() const { return &self; } }; -class InvoiceSignature { +class HolderCommitmentTransaction { private: - LDKInvoiceSignature self; + LDKHolderCommitmentTransaction self; public: - InvoiceSignature(const InvoiceSignature&) = delete; - InvoiceSignature(InvoiceSignature&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceSignature)); } - InvoiceSignature(LDKInvoiceSignature&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceSignature)); } - operator LDKInvoiceSignature() && { LDKInvoiceSignature res = self; memset(&self, 0, sizeof(LDKInvoiceSignature)); return res; } - ~InvoiceSignature() { InvoiceSignature_free(self); } - InvoiceSignature& operator=(InvoiceSignature&& o) { InvoiceSignature_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceSignature)); return *this; } - LDKInvoiceSignature* operator &() { return &self; } - LDKInvoiceSignature* operator ->() { return &self; } - const LDKInvoiceSignature* operator &() const { return &self; } - const LDKInvoiceSignature* operator ->() const { return &self; } + HolderCommitmentTransaction(const HolderCommitmentTransaction&) = delete; + HolderCommitmentTransaction(HolderCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(HolderCommitmentTransaction)); } + HolderCommitmentTransaction(LDKHolderCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHolderCommitmentTransaction)); } + operator LDKHolderCommitmentTransaction() && { LDKHolderCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKHolderCommitmentTransaction)); return res; } + ~HolderCommitmentTransaction() { HolderCommitmentTransaction_free(self); } + HolderCommitmentTransaction& operator=(HolderCommitmentTransaction&& o) { HolderCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(HolderCommitmentTransaction)); return *this; } + LDKHolderCommitmentTransaction* operator &() { return &self; } + LDKHolderCommitmentTransaction* operator ->() { return &self; } + const LDKHolderCommitmentTransaction* operator &() const { return &self; } + const LDKHolderCommitmentTransaction* operator ->() const { return &self; } }; -class PrivateRoute { +class BuiltCommitmentTransaction { private: - LDKPrivateRoute self; + LDKBuiltCommitmentTransaction self; public: - PrivateRoute(const PrivateRoute&) = delete; - PrivateRoute(PrivateRoute&& o) : self(o.self) { memset(&o, 0, sizeof(PrivateRoute)); } - PrivateRoute(LDKPrivateRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrivateRoute)); } - operator LDKPrivateRoute() && { LDKPrivateRoute res = self; memset(&self, 0, sizeof(LDKPrivateRoute)); return res; } - ~PrivateRoute() { PrivateRoute_free(self); } - PrivateRoute& operator=(PrivateRoute&& o) { PrivateRoute_free(self); self = o.self; memset(&o, 0, sizeof(PrivateRoute)); return *this; } - LDKPrivateRoute* operator &() { return &self; } - LDKPrivateRoute* operator ->() { return &self; } - const LDKPrivateRoute* operator &() const { return &self; } - const LDKPrivateRoute* operator ->() const { return &self; } + BuiltCommitmentTransaction(const BuiltCommitmentTransaction&) = delete; + BuiltCommitmentTransaction(BuiltCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(BuiltCommitmentTransaction)); } + BuiltCommitmentTransaction(LDKBuiltCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBuiltCommitmentTransaction)); } + operator LDKBuiltCommitmentTransaction() && { LDKBuiltCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKBuiltCommitmentTransaction)); return res; } + ~BuiltCommitmentTransaction() { BuiltCommitmentTransaction_free(self); } + BuiltCommitmentTransaction& operator=(BuiltCommitmentTransaction&& o) { BuiltCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(BuiltCommitmentTransaction)); return *this; } + LDKBuiltCommitmentTransaction* operator &() { return &self; } + LDKBuiltCommitmentTransaction* operator ->() { return &self; } + const LDKBuiltCommitmentTransaction* operator &() const { return &self; } + const LDKBuiltCommitmentTransaction* operator ->() const { return &self; } +}; +class ClosingTransaction { +private: + LDKClosingTransaction self; +public: + ClosingTransaction(const ClosingTransaction&) = delete; + ClosingTransaction(ClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingTransaction)); } + ClosingTransaction(LDKClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingTransaction)); } + operator LDKClosingTransaction() && { LDKClosingTransaction res = self; memset(&self, 0, sizeof(LDKClosingTransaction)); return res; } + ~ClosingTransaction() { ClosingTransaction_free(self); } + ClosingTransaction& operator=(ClosingTransaction&& o) { ClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(ClosingTransaction)); return *this; } + LDKClosingTransaction* operator &() { return &self; } + LDKClosingTransaction* operator ->() { return &self; } + const LDKClosingTransaction* operator &() const { return &self; } + const LDKClosingTransaction* operator ->() const { return &self; } }; -class CreationError { +class TrustedClosingTransaction { private: - LDKCreationError self; + LDKTrustedClosingTransaction self; public: - CreationError(const CreationError&) = delete; - CreationError(CreationError&& o) : self(o.self) { memset(&o, 0, sizeof(CreationError)); } - CreationError(LDKCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCreationError)); } - operator LDKCreationError() && { LDKCreationError res = self; memset(&self, 0, sizeof(LDKCreationError)); return res; } - CreationError& operator=(CreationError&& o) { self = o.self; memset(&o, 0, sizeof(CreationError)); return *this; } - LDKCreationError* operator &() { return &self; } - LDKCreationError* operator ->() { return &self; } - const LDKCreationError* operator &() const { return &self; } - const LDKCreationError* operator ->() const { return &self; } + TrustedClosingTransaction(const TrustedClosingTransaction&) = delete; + TrustedClosingTransaction(TrustedClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedClosingTransaction)); } + TrustedClosingTransaction(LDKTrustedClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedClosingTransaction)); } + operator LDKTrustedClosingTransaction() && { LDKTrustedClosingTransaction res = self; memset(&self, 0, sizeof(LDKTrustedClosingTransaction)); return res; } + ~TrustedClosingTransaction() { TrustedClosingTransaction_free(self); } + TrustedClosingTransaction& operator=(TrustedClosingTransaction&& o) { TrustedClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(TrustedClosingTransaction)); return *this; } + LDKTrustedClosingTransaction* operator &() { return &self; } + LDKTrustedClosingTransaction* operator ->() { return &self; } + const LDKTrustedClosingTransaction* operator &() const { return &self; } + const LDKTrustedClosingTransaction* operator ->() const { return &self; } }; -class SemanticError { +class CommitmentTransaction { private: - LDKSemanticError self; + LDKCommitmentTransaction self; public: - SemanticError(const SemanticError&) = delete; - SemanticError(SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(SemanticError)); } - SemanticError(LDKSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSemanticError)); } - operator LDKSemanticError() && { LDKSemanticError res = self; memset(&self, 0, sizeof(LDKSemanticError)); return res; } - SemanticError& operator=(SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(SemanticError)); return *this; } - LDKSemanticError* operator &() { return &self; } - LDKSemanticError* operator ->() { return &self; } - const LDKSemanticError* operator &() const { return &self; } - const LDKSemanticError* operator ->() const { return &self; } + CommitmentTransaction(const CommitmentTransaction&) = delete; + CommitmentTransaction(CommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentTransaction)); } + CommitmentTransaction(LDKCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentTransaction)); } + operator LDKCommitmentTransaction() && { LDKCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKCommitmentTransaction)); return res; } + ~CommitmentTransaction() { CommitmentTransaction_free(self); } + CommitmentTransaction& operator=(CommitmentTransaction&& o) { CommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentTransaction)); return *this; } + LDKCommitmentTransaction* operator &() { return &self; } + LDKCommitmentTransaction* operator ->() { return &self; } + const LDKCommitmentTransaction* operator &() const { return &self; } + const LDKCommitmentTransaction* operator ->() const { return &self; } }; -class SignOrCreationError { +class TrustedCommitmentTransaction { private: - LDKSignOrCreationError self; + LDKTrustedCommitmentTransaction self; public: - SignOrCreationError(const SignOrCreationError&) = delete; - SignOrCreationError(SignOrCreationError&& o) : self(o.self) { memset(&o, 0, sizeof(SignOrCreationError)); } - SignOrCreationError(LDKSignOrCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignOrCreationError)); } - operator LDKSignOrCreationError() && { LDKSignOrCreationError res = self; memset(&self, 0, sizeof(LDKSignOrCreationError)); return res; } - ~SignOrCreationError() { SignOrCreationError_free(self); } - SignOrCreationError& operator=(SignOrCreationError&& o) { SignOrCreationError_free(self); self = o.self; memset(&o, 0, sizeof(SignOrCreationError)); return *this; } - LDKSignOrCreationError* operator &() { return &self; } - LDKSignOrCreationError* operator ->() { return &self; } - const LDKSignOrCreationError* operator &() const { return &self; } - const LDKSignOrCreationError* operator ->() const { return &self; } + TrustedCommitmentTransaction(const TrustedCommitmentTransaction&) = delete; + TrustedCommitmentTransaction(TrustedCommitmentTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedCommitmentTransaction)); } + TrustedCommitmentTransaction(LDKTrustedCommitmentTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedCommitmentTransaction)); } + operator LDKTrustedCommitmentTransaction() && { LDKTrustedCommitmentTransaction res = self; memset(&self, 0, sizeof(LDKTrustedCommitmentTransaction)); return res; } + ~TrustedCommitmentTransaction() { TrustedCommitmentTransaction_free(self); } + TrustedCommitmentTransaction& operator=(TrustedCommitmentTransaction&& o) { TrustedCommitmentTransaction_free(self); self = o.self; memset(&o, 0, sizeof(TrustedCommitmentTransaction)); return *this; } + LDKTrustedCommitmentTransaction* operator &() { return &self; } + LDKTrustedCommitmentTransaction* operator ->() { return &self; } + const LDKTrustedCommitmentTransaction* operator &() const { return &self; } + const LDKTrustedCommitmentTransaction* operator ->() const { return &self; } }; -class Persister { +class ShutdownScript { private: - LDKPersister self; + LDKShutdownScript self; public: - Persister(const Persister&) = delete; - Persister(Persister&& o) : self(o.self) { memset(&o, 0, sizeof(Persister)); } - Persister(LDKPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersister)); } - operator LDKPersister() && { LDKPersister res = self; memset(&self, 0, sizeof(LDKPersister)); return res; } - ~Persister() { Persister_free(self); } - Persister& operator=(Persister&& o) { Persister_free(self); self = o.self; memset(&o, 0, sizeof(Persister)); return *this; } - LDKPersister* operator &() { return &self; } - LDKPersister* operator ->() { return &self; } - const LDKPersister* operator &() const { return &self; } - const LDKPersister* operator ->() const { return &self; } - /** - * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager); - /** - * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph); - /** - * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer); + ShutdownScript(const ShutdownScript&) = delete; + ShutdownScript(ShutdownScript&& o) : self(o.self) { memset(&o, 0, sizeof(ShutdownScript)); } + ShutdownScript(LDKShutdownScript&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShutdownScript)); } + operator LDKShutdownScript() && { LDKShutdownScript res = self; memset(&self, 0, sizeof(LDKShutdownScript)); return res; } + ~ShutdownScript() { ShutdownScript_free(self); } + ShutdownScript& operator=(ShutdownScript&& o) { ShutdownScript_free(self); self = o.self; memset(&o, 0, sizeof(ShutdownScript)); return *this; } + LDKShutdownScript* operator &() { return &self; } + LDKShutdownScript* operator ->() { return &self; } + const LDKShutdownScript* operator &() const { return &self; } + const LDKShutdownScript* operator ->() const { return &self; } }; -class DecodeError { +class InvalidShutdownScript { private: - LDKDecodeError self; + LDKInvalidShutdownScript self; public: - DecodeError(const DecodeError&) = delete; - DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); } - DecodeError(LDKDecodeError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDecodeError)); } - operator LDKDecodeError() && { LDKDecodeError res = self; memset(&self, 0, sizeof(LDKDecodeError)); return res; } - ~DecodeError() { DecodeError_free(self); } - DecodeError& operator=(DecodeError&& o) { DecodeError_free(self); self = o.self; memset(&o, 0, sizeof(DecodeError)); return *this; } - LDKDecodeError* operator &() { return &self; } - LDKDecodeError* operator ->() { return &self; } - const LDKDecodeError* operator &() const { return &self; } - const LDKDecodeError* operator ->() const { return &self; } + InvalidShutdownScript(const InvalidShutdownScript&) = delete; + InvalidShutdownScript(InvalidShutdownScript&& o) : self(o.self) { memset(&o, 0, sizeof(InvalidShutdownScript)); } + InvalidShutdownScript(LDKInvalidShutdownScript&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvalidShutdownScript)); } + operator LDKInvalidShutdownScript() && { LDKInvalidShutdownScript res = self; memset(&self, 0, sizeof(LDKInvalidShutdownScript)); return res; } + ~InvalidShutdownScript() { InvalidShutdownScript_free(self); } + InvalidShutdownScript& operator=(InvalidShutdownScript&& o) { InvalidShutdownScript_free(self); self = o.self; memset(&o, 0, sizeof(InvalidShutdownScript)); return *this; } + LDKInvalidShutdownScript* operator &() { return &self; } + LDKInvalidShutdownScript* operator ->() { return &self; } + const LDKInvalidShutdownScript* operator &() const { return &self; } + const LDKInvalidShutdownScript* operator ->() const { return &self; } }; -class Init { +class Bolt12ParseError { private: - LDKInit self; + LDKBolt12ParseError self; public: - Init(const Init&) = delete; - Init(Init&& o) : self(o.self) { memset(&o, 0, sizeof(Init)); } - Init(LDKInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInit)); } - operator LDKInit() && { LDKInit res = self; memset(&self, 0, sizeof(LDKInit)); return res; } - ~Init() { Init_free(self); } - Init& operator=(Init&& o) { Init_free(self); self = o.self; memset(&o, 0, sizeof(Init)); return *this; } - LDKInit* operator &() { return &self; } - LDKInit* operator ->() { return &self; } - const LDKInit* operator &() const { return &self; } - const LDKInit* operator ->() const { return &self; } + Bolt12ParseError(const Bolt12ParseError&) = delete; + Bolt12ParseError(Bolt12ParseError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12ParseError)); } + Bolt12ParseError(LDKBolt12ParseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12ParseError)); } + operator LDKBolt12ParseError() && { LDKBolt12ParseError res = self; memset(&self, 0, sizeof(LDKBolt12ParseError)); return res; } + ~Bolt12ParseError() { Bolt12ParseError_free(self); } + Bolt12ParseError& operator=(Bolt12ParseError&& o) { Bolt12ParseError_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12ParseError)); return *this; } + LDKBolt12ParseError* operator &() { return &self; } + LDKBolt12ParseError* operator ->() { return &self; } + const LDKBolt12ParseError* operator &() const { return &self; } + const LDKBolt12ParseError* operator ->() const { return &self; } }; -class ErrorMessage { +class Bolt12SemanticError { private: - LDKErrorMessage self; + LDKBolt12SemanticError self; public: - ErrorMessage(const ErrorMessage&) = delete; - ErrorMessage(ErrorMessage&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorMessage)); } - ErrorMessage(LDKErrorMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorMessage)); } - operator LDKErrorMessage() && { LDKErrorMessage res = self; memset(&self, 0, sizeof(LDKErrorMessage)); return res; } - ~ErrorMessage() { ErrorMessage_free(self); } - ErrorMessage& operator=(ErrorMessage&& o) { ErrorMessage_free(self); self = o.self; memset(&o, 0, sizeof(ErrorMessage)); return *this; } - LDKErrorMessage* operator &() { return &self; } - LDKErrorMessage* operator ->() { return &self; } - const LDKErrorMessage* operator &() const { return &self; } - const LDKErrorMessage* operator ->() const { return &self; } + Bolt12SemanticError(const Bolt12SemanticError&) = delete; + Bolt12SemanticError(Bolt12SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12SemanticError)); } + Bolt12SemanticError(LDKBolt12SemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12SemanticError)); } + operator LDKBolt12SemanticError() && { LDKBolt12SemanticError res = self; memset(&self, 0, sizeof(LDKBolt12SemanticError)); return res; } + Bolt12SemanticError& operator=(Bolt12SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(Bolt12SemanticError)); return *this; } + LDKBolt12SemanticError* operator &() { return &self; } + LDKBolt12SemanticError* operator ->() { return &self; } + const LDKBolt12SemanticError* operator &() const { return &self; } + const LDKBolt12SemanticError* operator ->() const { return &self; } }; -class WarningMessage { +class BroadcasterInterface { private: - LDKWarningMessage self; + LDKBroadcasterInterface self; public: - WarningMessage(const WarningMessage&) = delete; - WarningMessage(WarningMessage&& o) : self(o.self) { memset(&o, 0, sizeof(WarningMessage)); } - WarningMessage(LDKWarningMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWarningMessage)); } - operator LDKWarningMessage() && { LDKWarningMessage res = self; memset(&self, 0, sizeof(LDKWarningMessage)); return res; } - ~WarningMessage() { WarningMessage_free(self); } - WarningMessage& operator=(WarningMessage&& o) { WarningMessage_free(self); self = o.self; memset(&o, 0, sizeof(WarningMessage)); return *this; } - LDKWarningMessage* operator &() { return &self; } - LDKWarningMessage* operator ->() { return &self; } - const LDKWarningMessage* operator &() const { return &self; } - const LDKWarningMessage* operator ->() const { return &self; } + BroadcasterInterface(const BroadcasterInterface&) = delete; + BroadcasterInterface(BroadcasterInterface&& o) : self(o.self) { memset(&o, 0, sizeof(BroadcasterInterface)); } + BroadcasterInterface(LDKBroadcasterInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBroadcasterInterface)); } + operator LDKBroadcasterInterface() && { LDKBroadcasterInterface res = self; memset(&self, 0, sizeof(LDKBroadcasterInterface)); return res; } + ~BroadcasterInterface() { BroadcasterInterface_free(self); } + BroadcasterInterface& operator=(BroadcasterInterface&& o) { BroadcasterInterface_free(self); self = o.self; memset(&o, 0, sizeof(BroadcasterInterface)); return *this; } + LDKBroadcasterInterface* operator &() { return &self; } + LDKBroadcasterInterface* operator ->() { return &self; } + const LDKBroadcasterInterface* operator &() const { return &self; } + const LDKBroadcasterInterface* operator ->() const { return &self; } + /** + * Sends a list of transactions out to (hopefully) be mined. + * This only needs to handle the actual broadcasting of transactions, LDK will automatically + * rebroadcast transactions that haven't made it into a block. + * + * In some cases LDK may attempt to broadcast a transaction which double-spends another + * and this isn't a bug and can be safely ignored. + * + * If more than one transaction is given, these transactions should be considered to be a + * package and broadcast together. Some of the transactions may or may not depend on each other, + * be sure to manage both cases correctly. + * + * Bitcoin transaction packages are defined in BIP 331 and here: + * https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md + */ + inline void broadcast_transactions(struct LDKCVec_TransactionZ txs); }; -class Ping { +class ConfirmationTarget { private: - LDKPing self; + LDKConfirmationTarget self; public: - Ping(const Ping&) = delete; - Ping(Ping&& o) : self(o.self) { memset(&o, 0, sizeof(Ping)); } - Ping(LDKPing&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPing)); } - operator LDKPing() && { LDKPing res = self; memset(&self, 0, sizeof(LDKPing)); return res; } - ~Ping() { Ping_free(self); } - Ping& operator=(Ping&& o) { Ping_free(self); self = o.self; memset(&o, 0, sizeof(Ping)); return *this; } - LDKPing* operator &() { return &self; } - LDKPing* operator ->() { return &self; } - const LDKPing* operator &() const { return &self; } - const LDKPing* operator ->() const { return &self; } + ConfirmationTarget(const ConfirmationTarget&) = delete; + ConfirmationTarget(ConfirmationTarget&& o) : self(o.self) { memset(&o, 0, sizeof(ConfirmationTarget)); } + ConfirmationTarget(LDKConfirmationTarget&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKConfirmationTarget)); } + operator LDKConfirmationTarget() && { LDKConfirmationTarget res = self; memset(&self, 0, sizeof(LDKConfirmationTarget)); return res; } + ConfirmationTarget& operator=(ConfirmationTarget&& o) { self = o.self; memset(&o, 0, sizeof(ConfirmationTarget)); return *this; } + LDKConfirmationTarget* operator &() { return &self; } + LDKConfirmationTarget* operator ->() { return &self; } + const LDKConfirmationTarget* operator &() const { return &self; } + const LDKConfirmationTarget* operator ->() const { return &self; } }; -class Pong { +class FeeEstimator { private: - LDKPong self; + LDKFeeEstimator self; public: - Pong(const Pong&) = delete; - Pong(Pong&& o) : self(o.self) { memset(&o, 0, sizeof(Pong)); } - Pong(LDKPong&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPong)); } - operator LDKPong() && { LDKPong res = self; memset(&self, 0, sizeof(LDKPong)); return res; } - ~Pong() { Pong_free(self); } - Pong& operator=(Pong&& o) { Pong_free(self); self = o.self; memset(&o, 0, sizeof(Pong)); return *this; } - LDKPong* operator &() { return &self; } - LDKPong* operator ->() { return &self; } - const LDKPong* operator &() const { return &self; } - const LDKPong* operator ->() const { return &self; } + FeeEstimator(const FeeEstimator&) = delete; + FeeEstimator(FeeEstimator&& o) : self(o.self) { memset(&o, 0, sizeof(FeeEstimator)); } + FeeEstimator(LDKFeeEstimator&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFeeEstimator)); } + operator LDKFeeEstimator() && { LDKFeeEstimator res = self; memset(&self, 0, sizeof(LDKFeeEstimator)); return res; } + ~FeeEstimator() { FeeEstimator_free(self); } + FeeEstimator& operator=(FeeEstimator&& o) { FeeEstimator_free(self); self = o.self; memset(&o, 0, sizeof(FeeEstimator)); return *this; } + LDKFeeEstimator* operator &() { return &self; } + LDKFeeEstimator* operator ->() { return &self; } + const LDKFeeEstimator* operator &() const { return &self; } + const LDKFeeEstimator* operator ->() const { return &self; } + /** + * Gets estimated satoshis of fee required per 1000 Weight-Units. + * + * LDK will wrap this method and ensure that the value returned is no smaller than 253 + * (ie 1 satoshi-per-byte rounded up to ensure later round-downs don't put us below 1 satoshi-per-byte). + * + * The following unit conversions can be used to convert to sats/KW: + * * satoshis-per-byte * 250 + * * satoshis-per-kbyte / 4 + */ + inline uint32_t get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target); }; -class OpenChannel { +class OnionMessageContents { private: - LDKOpenChannel self; + LDKOnionMessageContents self; public: - OpenChannel(const OpenChannel&) = delete; - OpenChannel(OpenChannel&& o) : self(o.self) { memset(&o, 0, sizeof(OpenChannel)); } - OpenChannel(LDKOpenChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOpenChannel)); } - operator LDKOpenChannel() && { LDKOpenChannel res = self; memset(&self, 0, sizeof(LDKOpenChannel)); return res; } - ~OpenChannel() { OpenChannel_free(self); } - OpenChannel& operator=(OpenChannel&& o) { OpenChannel_free(self); self = o.self; memset(&o, 0, sizeof(OpenChannel)); return *this; } - LDKOpenChannel* operator &() { return &self; } - LDKOpenChannel* operator ->() { return &self; } - const LDKOpenChannel* operator &() const { return &self; } - const LDKOpenChannel* operator ->() const { return &self; } + OnionMessageContents(const OnionMessageContents&) = delete; + OnionMessageContents(OnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageContents)); } + OnionMessageContents(LDKOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageContents)); } + operator LDKOnionMessageContents() && { LDKOnionMessageContents res = self; memset(&self, 0, sizeof(LDKOnionMessageContents)); return res; } + ~OnionMessageContents() { OnionMessageContents_free(self); } + OnionMessageContents& operator=(OnionMessageContents&& o) { OnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageContents)); return *this; } + LDKOnionMessageContents* operator &() { return &self; } + LDKOnionMessageContents* operator ->() { return &self; } + const LDKOnionMessageContents* operator &() const { return &self; } + const LDKOnionMessageContents* operator ->() const { return &self; } }; -class AcceptChannel { +class CustomOnionMessageContents { private: - LDKAcceptChannel self; + LDKCustomOnionMessageContents self; public: - AcceptChannel(const AcceptChannel&) = delete; - AcceptChannel(AcceptChannel&& o) : self(o.self) { memset(&o, 0, sizeof(AcceptChannel)); } - AcceptChannel(LDKAcceptChannel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAcceptChannel)); } - operator LDKAcceptChannel() && { LDKAcceptChannel res = self; memset(&self, 0, sizeof(LDKAcceptChannel)); return res; } - ~AcceptChannel() { AcceptChannel_free(self); } - AcceptChannel& operator=(AcceptChannel&& o) { AcceptChannel_free(self); self = o.self; memset(&o, 0, sizeof(AcceptChannel)); return *this; } - LDKAcceptChannel* operator &() { return &self; } - LDKAcceptChannel* operator ->() { return &self; } - const LDKAcceptChannel* operator &() const { return &self; } - const LDKAcceptChannel* operator ->() const { return &self; } + CustomOnionMessageContents(const CustomOnionMessageContents&) = delete; + CustomOnionMessageContents(CustomOnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageContents)); } + CustomOnionMessageContents(LDKCustomOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageContents)); } + operator LDKCustomOnionMessageContents() && { LDKCustomOnionMessageContents res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageContents)); return res; } + ~CustomOnionMessageContents() { CustomOnionMessageContents_free(self); } + CustomOnionMessageContents& operator=(CustomOnionMessageContents&& o) { CustomOnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageContents)); return *this; } + LDKCustomOnionMessageContents* operator &() { return &self; } + LDKCustomOnionMessageContents* operator ->() { return &self; } + const LDKCustomOnionMessageContents* operator &() const { return &self; } + const LDKCustomOnionMessageContents* operator ->() const { return &self; } + /** + * Returns the TLV type identifying the message contents. MUST be >= 64. + */ + inline uint64_t tlv_type(); }; -class FundingCreated { +class PaymentPurpose { private: - LDKFundingCreated self; + LDKPaymentPurpose self; public: - FundingCreated(const FundingCreated&) = delete; - FundingCreated(FundingCreated&& o) : self(o.self) { memset(&o, 0, sizeof(FundingCreated)); } - FundingCreated(LDKFundingCreated&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingCreated)); } - operator LDKFundingCreated() && { LDKFundingCreated res = self; memset(&self, 0, sizeof(LDKFundingCreated)); return res; } - ~FundingCreated() { FundingCreated_free(self); } - FundingCreated& operator=(FundingCreated&& o) { FundingCreated_free(self); self = o.self; memset(&o, 0, sizeof(FundingCreated)); return *this; } - LDKFundingCreated* operator &() { return &self; } - LDKFundingCreated* operator ->() { return &self; } - const LDKFundingCreated* operator &() const { return &self; } - const LDKFundingCreated* operator ->() const { return &self; } + PaymentPurpose(const PaymentPurpose&) = delete; + PaymentPurpose(PaymentPurpose&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentPurpose)); } + PaymentPurpose(LDKPaymentPurpose&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentPurpose)); } + operator LDKPaymentPurpose() && { LDKPaymentPurpose res = self; memset(&self, 0, sizeof(LDKPaymentPurpose)); return res; } + ~PaymentPurpose() { PaymentPurpose_free(self); } + PaymentPurpose& operator=(PaymentPurpose&& o) { PaymentPurpose_free(self); self = o.self; memset(&o, 0, sizeof(PaymentPurpose)); return *this; } + LDKPaymentPurpose* operator &() { return &self; } + LDKPaymentPurpose* operator ->() { return &self; } + const LDKPaymentPurpose* operator &() const { return &self; } + const LDKPaymentPurpose* operator ->() const { return &self; } }; -class FundingSigned { +class PathFailure { private: - LDKFundingSigned self; + LDKPathFailure self; public: - FundingSigned(const FundingSigned&) = delete; - FundingSigned(FundingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(FundingSigned)); } - FundingSigned(LDKFundingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingSigned)); } - operator LDKFundingSigned() && { LDKFundingSigned res = self; memset(&self, 0, sizeof(LDKFundingSigned)); return res; } - ~FundingSigned() { FundingSigned_free(self); } - FundingSigned& operator=(FundingSigned&& o) { FundingSigned_free(self); self = o.self; memset(&o, 0, sizeof(FundingSigned)); return *this; } - LDKFundingSigned* operator &() { return &self; } - LDKFundingSigned* operator ->() { return &self; } - const LDKFundingSigned* operator &() const { return &self; } - const LDKFundingSigned* operator ->() const { return &self; } + PathFailure(const PathFailure&) = delete; + PathFailure(PathFailure&& o) : self(o.self) { memset(&o, 0, sizeof(PathFailure)); } + PathFailure(LDKPathFailure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPathFailure)); } + operator LDKPathFailure() && { LDKPathFailure res = self; memset(&self, 0, sizeof(LDKPathFailure)); return res; } + ~PathFailure() { PathFailure_free(self); } + PathFailure& operator=(PathFailure&& o) { PathFailure_free(self); self = o.self; memset(&o, 0, sizeof(PathFailure)); return *this; } + LDKPathFailure* operator &() { return &self; } + LDKPathFailure* operator ->() { return &self; } + const LDKPathFailure* operator &() const { return &self; } + const LDKPathFailure* operator ->() const { return &self; } }; -class ChannelReady { +class ClosureReason { private: - LDKChannelReady self; + LDKClosureReason self; public: - ChannelReady(const ChannelReady&) = delete; - ChannelReady(ChannelReady&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelReady)); } - ChannelReady(LDKChannelReady&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelReady)); } - operator LDKChannelReady() && { LDKChannelReady res = self; memset(&self, 0, sizeof(LDKChannelReady)); return res; } - ~ChannelReady() { ChannelReady_free(self); } - ChannelReady& operator=(ChannelReady&& o) { ChannelReady_free(self); self = o.self; memset(&o, 0, sizeof(ChannelReady)); return *this; } - LDKChannelReady* operator &() { return &self; } - LDKChannelReady* operator ->() { return &self; } - const LDKChannelReady* operator &() const { return &self; } - const LDKChannelReady* operator ->() const { return &self; } + ClosureReason(const ClosureReason&) = delete; + ClosureReason(ClosureReason&& o) : self(o.self) { memset(&o, 0, sizeof(ClosureReason)); } + ClosureReason(LDKClosureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosureReason)); } + operator LDKClosureReason() && { LDKClosureReason res = self; memset(&self, 0, sizeof(LDKClosureReason)); return res; } + ~ClosureReason() { ClosureReason_free(self); } + ClosureReason& operator=(ClosureReason&& o) { ClosureReason_free(self); self = o.self; memset(&o, 0, sizeof(ClosureReason)); return *this; } + LDKClosureReason* operator &() { return &self; } + LDKClosureReason* operator ->() { return &self; } + const LDKClosureReason* operator &() const { return &self; } + const LDKClosureReason* operator ->() const { return &self; } }; -class Shutdown { +class HTLCDestination { private: - LDKShutdown self; + LDKHTLCDestination self; public: - Shutdown(const Shutdown&) = delete; - Shutdown(Shutdown&& o) : self(o.self) { memset(&o, 0, sizeof(Shutdown)); } - Shutdown(LDKShutdown&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShutdown)); } - operator LDKShutdown() && { LDKShutdown res = self; memset(&self, 0, sizeof(LDKShutdown)); return res; } - ~Shutdown() { Shutdown_free(self); } - Shutdown& operator=(Shutdown&& o) { Shutdown_free(self); self = o.self; memset(&o, 0, sizeof(Shutdown)); return *this; } - LDKShutdown* operator &() { return &self; } - LDKShutdown* operator ->() { return &self; } - const LDKShutdown* operator &() const { return &self; } - const LDKShutdown* operator ->() const { return &self; } + HTLCDestination(const HTLCDestination&) = delete; + HTLCDestination(HTLCDestination&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCDestination)); } + HTLCDestination(LDKHTLCDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCDestination)); } + operator LDKHTLCDestination() && { LDKHTLCDestination res = self; memset(&self, 0, sizeof(LDKHTLCDestination)); return res; } + ~HTLCDestination() { HTLCDestination_free(self); } + HTLCDestination& operator=(HTLCDestination&& o) { HTLCDestination_free(self); self = o.self; memset(&o, 0, sizeof(HTLCDestination)); return *this; } + LDKHTLCDestination* operator &() { return &self; } + LDKHTLCDestination* operator ->() { return &self; } + const LDKHTLCDestination* operator &() const { return &self; } + const LDKHTLCDestination* operator ->() const { return &self; } }; -class ClosingSignedFeeRange { +class PaymentFailureReason { private: - LDKClosingSignedFeeRange self; + LDKPaymentFailureReason self; public: - ClosingSignedFeeRange(const ClosingSignedFeeRange&) = delete; - ClosingSignedFeeRange(ClosingSignedFeeRange&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingSignedFeeRange)); } - ClosingSignedFeeRange(LDKClosingSignedFeeRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingSignedFeeRange)); } - operator LDKClosingSignedFeeRange() && { LDKClosingSignedFeeRange res = self; memset(&self, 0, sizeof(LDKClosingSignedFeeRange)); return res; } - ~ClosingSignedFeeRange() { ClosingSignedFeeRange_free(self); } - ClosingSignedFeeRange& operator=(ClosingSignedFeeRange&& o) { ClosingSignedFeeRange_free(self); self = o.self; memset(&o, 0, sizeof(ClosingSignedFeeRange)); return *this; } - LDKClosingSignedFeeRange* operator &() { return &self; } - LDKClosingSignedFeeRange* operator ->() { return &self; } - const LDKClosingSignedFeeRange* operator &() const { return &self; } - const LDKClosingSignedFeeRange* operator ->() const { return &self; } + PaymentFailureReason(const PaymentFailureReason&) = delete; + PaymentFailureReason(PaymentFailureReason&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentFailureReason)); } + PaymentFailureReason(LDKPaymentFailureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentFailureReason)); } + operator LDKPaymentFailureReason() && { LDKPaymentFailureReason res = self; memset(&self, 0, sizeof(LDKPaymentFailureReason)); return res; } + PaymentFailureReason& operator=(PaymentFailureReason&& o) { self = o.self; memset(&o, 0, sizeof(PaymentFailureReason)); return *this; } + LDKPaymentFailureReason* operator &() { return &self; } + LDKPaymentFailureReason* operator ->() { return &self; } + const LDKPaymentFailureReason* operator &() const { return &self; } + const LDKPaymentFailureReason* operator ->() const { return &self; } }; -class ClosingSigned { +class Event { private: - LDKClosingSigned self; + LDKEvent self; public: - ClosingSigned(const ClosingSigned&) = delete; - ClosingSigned(ClosingSigned&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingSigned)); } - ClosingSigned(LDKClosingSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingSigned)); } - operator LDKClosingSigned() && { LDKClosingSigned res = self; memset(&self, 0, sizeof(LDKClosingSigned)); return res; } - ~ClosingSigned() { ClosingSigned_free(self); } - ClosingSigned& operator=(ClosingSigned&& o) { ClosingSigned_free(self); self = o.self; memset(&o, 0, sizeof(ClosingSigned)); return *this; } - LDKClosingSigned* operator &() { return &self; } - LDKClosingSigned* operator ->() { return &self; } - const LDKClosingSigned* operator &() const { return &self; } - const LDKClosingSigned* operator ->() const { return &self; } + Event(const Event&) = delete; + Event(Event&& o) : self(o.self) { memset(&o, 0, sizeof(Event)); } + Event(LDKEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEvent)); } + operator LDKEvent() && { LDKEvent res = self; memset(&self, 0, sizeof(LDKEvent)); return res; } + ~Event() { Event_free(self); } + Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } + LDKEvent* operator &() { return &self; } + LDKEvent* operator ->() { return &self; } + const LDKEvent* operator &() const { return &self; } + const LDKEvent* operator ->() const { return &self; } }; -class UpdateAddHTLC { +class MessageSendEvent { private: - LDKUpdateAddHTLC self; + LDKMessageSendEvent self; public: - UpdateAddHTLC(const UpdateAddHTLC&) = delete; - UpdateAddHTLC(UpdateAddHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateAddHTLC)); } - UpdateAddHTLC(LDKUpdateAddHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateAddHTLC)); } - operator LDKUpdateAddHTLC() && { LDKUpdateAddHTLC res = self; memset(&self, 0, sizeof(LDKUpdateAddHTLC)); return res; } - ~UpdateAddHTLC() { UpdateAddHTLC_free(self); } - UpdateAddHTLC& operator=(UpdateAddHTLC&& o) { UpdateAddHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateAddHTLC)); return *this; } - LDKUpdateAddHTLC* operator &() { return &self; } - LDKUpdateAddHTLC* operator ->() { return &self; } - const LDKUpdateAddHTLC* operator &() const { return &self; } - const LDKUpdateAddHTLC* operator ->() const { return &self; } + MessageSendEvent(const MessageSendEvent&) = delete; + MessageSendEvent(MessageSendEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEvent)); } + MessageSendEvent(LDKMessageSendEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEvent)); } + operator LDKMessageSendEvent() && { LDKMessageSendEvent res = self; memset(&self, 0, sizeof(LDKMessageSendEvent)); return res; } + ~MessageSendEvent() { MessageSendEvent_free(self); } + MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } + LDKMessageSendEvent* operator &() { return &self; } + LDKMessageSendEvent* operator ->() { return &self; } + const LDKMessageSendEvent* operator &() const { return &self; } + const LDKMessageSendEvent* operator ->() const { return &self; } }; -class OnionMessage { +class MessageSendEventsProvider { private: - LDKOnionMessage self; + LDKMessageSendEventsProvider self; public: - OnionMessage(const OnionMessage&) = delete; - OnionMessage(OnionMessage&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessage)); } - OnionMessage(LDKOnionMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessage)); } - operator LDKOnionMessage() && { LDKOnionMessage res = self; memset(&self, 0, sizeof(LDKOnionMessage)); return res; } - ~OnionMessage() { OnionMessage_free(self); } - OnionMessage& operator=(OnionMessage&& o) { OnionMessage_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessage)); return *this; } - LDKOnionMessage* operator &() { return &self; } - LDKOnionMessage* operator ->() { return &self; } - const LDKOnionMessage* operator &() const { return &self; } - const LDKOnionMessage* operator ->() const { return &self; } + MessageSendEventsProvider(const MessageSendEventsProvider&) = delete; + MessageSendEventsProvider(MessageSendEventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEventsProvider)); } + MessageSendEventsProvider(LDKMessageSendEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEventsProvider)); } + operator LDKMessageSendEventsProvider() && { LDKMessageSendEventsProvider res = self; memset(&self, 0, sizeof(LDKMessageSendEventsProvider)); return res; } + ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } + MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } + LDKMessageSendEventsProvider* operator &() { return &self; } + LDKMessageSendEventsProvider* operator ->() { return &self; } + const LDKMessageSendEventsProvider* operator &() const { return &self; } + const LDKMessageSendEventsProvider* operator ->() const { return &self; } + /** + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. + */ + inline LDK::CVec_MessageSendEventZ get_and_clear_pending_msg_events(); }; -class UpdateFulfillHTLC { +class OnionMessageProvider { private: - LDKUpdateFulfillHTLC self; + LDKOnionMessageProvider self; public: - UpdateFulfillHTLC(const UpdateFulfillHTLC&) = delete; - UpdateFulfillHTLC(UpdateFulfillHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFulfillHTLC)); } - UpdateFulfillHTLC(LDKUpdateFulfillHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFulfillHTLC)); } - operator LDKUpdateFulfillHTLC() && { LDKUpdateFulfillHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFulfillHTLC)); return res; } - ~UpdateFulfillHTLC() { UpdateFulfillHTLC_free(self); } - UpdateFulfillHTLC& operator=(UpdateFulfillHTLC&& o) { UpdateFulfillHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFulfillHTLC)); return *this; } - LDKUpdateFulfillHTLC* operator &() { return &self; } - LDKUpdateFulfillHTLC* operator ->() { return &self; } - const LDKUpdateFulfillHTLC* operator &() const { return &self; } - const LDKUpdateFulfillHTLC* operator ->() const { return &self; } + OnionMessageProvider(const OnionMessageProvider&) = delete; + OnionMessageProvider(OnionMessageProvider&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageProvider)); } + OnionMessageProvider(LDKOnionMessageProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageProvider)); } + operator LDKOnionMessageProvider() && { LDKOnionMessageProvider res = self; memset(&self, 0, sizeof(LDKOnionMessageProvider)); return res; } + ~OnionMessageProvider() { OnionMessageProvider_free(self); } + OnionMessageProvider& operator=(OnionMessageProvider&& o) { OnionMessageProvider_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageProvider)); return *this; } + LDKOnionMessageProvider* operator &() { return &self; } + LDKOnionMessageProvider* operator ->() { return &self; } + const LDKOnionMessageProvider* operator &() const { return &self; } + const LDKOnionMessageProvider* operator ->() const { return &self; } + /** + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::OnionMessage next_onion_message_for_peer(struct LDKPublicKey peer_node_id); }; -class UpdateFailHTLC { +class EventsProvider { private: - LDKUpdateFailHTLC self; + LDKEventsProvider self; public: - UpdateFailHTLC(const UpdateFailHTLC&) = delete; - UpdateFailHTLC(UpdateFailHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailHTLC)); } - UpdateFailHTLC(LDKUpdateFailHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailHTLC)); } - operator LDKUpdateFailHTLC() && { LDKUpdateFailHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailHTLC)); return res; } - ~UpdateFailHTLC() { UpdateFailHTLC_free(self); } - UpdateFailHTLC& operator=(UpdateFailHTLC&& o) { UpdateFailHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFailHTLC)); return *this; } - LDKUpdateFailHTLC* operator &() { return &self; } - LDKUpdateFailHTLC* operator ->() { return &self; } - const LDKUpdateFailHTLC* operator &() const { return &self; } - const LDKUpdateFailHTLC* operator ->() const { return &self; } + EventsProvider(const EventsProvider&) = delete; + EventsProvider(EventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(EventsProvider)); } + EventsProvider(LDKEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventsProvider)); } + operator LDKEventsProvider() && { LDKEventsProvider res = self; memset(&self, 0, sizeof(LDKEventsProvider)); return res; } + ~EventsProvider() { EventsProvider_free(self); } + EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } + LDKEventsProvider* operator &() { return &self; } + LDKEventsProvider* operator ->() { return &self; } + const LDKEventsProvider* operator &() const { return &self; } + const LDKEventsProvider* operator ->() const { return &self; } + /** + * Processes any events generated since the last call using the given event handler. + * + * See the trait-level documentation for requirements. + */ + inline void process_pending_events(struct LDKEventHandler handler); }; -class UpdateFailMalformedHTLC { +class EventHandler { private: - LDKUpdateFailMalformedHTLC self; + LDKEventHandler self; public: - UpdateFailMalformedHTLC(const UpdateFailMalformedHTLC&) = delete; - UpdateFailMalformedHTLC(UpdateFailMalformedHTLC&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFailMalformedHTLC)); } - UpdateFailMalformedHTLC(LDKUpdateFailMalformedHTLC&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFailMalformedHTLC)); } - operator LDKUpdateFailMalformedHTLC() && { LDKUpdateFailMalformedHTLC res = self; memset(&self, 0, sizeof(LDKUpdateFailMalformedHTLC)); return res; } - ~UpdateFailMalformedHTLC() { UpdateFailMalformedHTLC_free(self); } - UpdateFailMalformedHTLC& operator=(UpdateFailMalformedHTLC&& o) { UpdateFailMalformedHTLC_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFailMalformedHTLC)); return *this; } - LDKUpdateFailMalformedHTLC* operator &() { return &self; } - LDKUpdateFailMalformedHTLC* operator ->() { return &self; } - const LDKUpdateFailMalformedHTLC* operator &() const { return &self; } - const LDKUpdateFailMalformedHTLC* operator ->() const { return &self; } + EventHandler(const EventHandler&) = delete; + EventHandler(EventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(EventHandler)); } + EventHandler(LDKEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventHandler)); } + operator LDKEventHandler() && { LDKEventHandler res = self; memset(&self, 0, sizeof(LDKEventHandler)); return res; } + ~EventHandler() { EventHandler_free(self); } + EventHandler& operator=(EventHandler&& o) { EventHandler_free(self); self = o.self; memset(&o, 0, sizeof(EventHandler)); return *this; } + LDKEventHandler* operator &() { return &self; } + LDKEventHandler* operator ->() { return &self; } + const LDKEventHandler* operator &() const { return &self; } + const LDKEventHandler* operator ->() const { return &self; } + /** + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. + */ + inline void handle_event(struct LDKEvent event); }; -class CommitmentSigned { +class FilesystemPersister { private: - LDKCommitmentSigned self; + LDKFilesystemPersister self; public: - CommitmentSigned(const CommitmentSigned&) = delete; - CommitmentSigned(CommitmentSigned&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentSigned)); } - CommitmentSigned(LDKCommitmentSigned&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentSigned)); } - operator LDKCommitmentSigned() && { LDKCommitmentSigned res = self; memset(&self, 0, sizeof(LDKCommitmentSigned)); return res; } - ~CommitmentSigned() { CommitmentSigned_free(self); } - CommitmentSigned& operator=(CommitmentSigned&& o) { CommitmentSigned_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentSigned)); return *this; } - LDKCommitmentSigned* operator &() { return &self; } - LDKCommitmentSigned* operator ->() { return &self; } - const LDKCommitmentSigned* operator &() const { return &self; } - const LDKCommitmentSigned* operator ->() const { return &self; } + FilesystemPersister(const FilesystemPersister&) = delete; + FilesystemPersister(FilesystemPersister&& o) : self(o.self) { memset(&o, 0, sizeof(FilesystemPersister)); } + FilesystemPersister(LDKFilesystemPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilesystemPersister)); } + operator LDKFilesystemPersister() && { LDKFilesystemPersister res = self; memset(&self, 0, sizeof(LDKFilesystemPersister)); return res; } + ~FilesystemPersister() { FilesystemPersister_free(self); } + FilesystemPersister& operator=(FilesystemPersister&& o) { FilesystemPersister_free(self); self = o.self; memset(&o, 0, sizeof(FilesystemPersister)); return *this; } + LDKFilesystemPersister* operator &() { return &self; } + LDKFilesystemPersister* operator ->() { return &self; } + const LDKFilesystemPersister* operator &() const { return &self; } + const LDKFilesystemPersister* operator ->() const { return &self; } }; -class RevokeAndACK { +class Bolt11ParseError { private: - LDKRevokeAndACK self; + LDKBolt11ParseError self; public: - RevokeAndACK(const RevokeAndACK&) = delete; - RevokeAndACK(RevokeAndACK&& o) : self(o.self) { memset(&o, 0, sizeof(RevokeAndACK)); } - RevokeAndACK(LDKRevokeAndACK&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRevokeAndACK)); } - operator LDKRevokeAndACK() && { LDKRevokeAndACK res = self; memset(&self, 0, sizeof(LDKRevokeAndACK)); return res; } - ~RevokeAndACK() { RevokeAndACK_free(self); } - RevokeAndACK& operator=(RevokeAndACK&& o) { RevokeAndACK_free(self); self = o.self; memset(&o, 0, sizeof(RevokeAndACK)); return *this; } - LDKRevokeAndACK* operator &() { return &self; } - LDKRevokeAndACK* operator ->() { return &self; } - const LDKRevokeAndACK* operator &() const { return &self; } - const LDKRevokeAndACK* operator ->() const { return &self; } + Bolt11ParseError(const Bolt11ParseError&) = delete; + Bolt11ParseError(Bolt11ParseError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11ParseError)); } + Bolt11ParseError(LDKBolt11ParseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11ParseError)); } + operator LDKBolt11ParseError() && { LDKBolt11ParseError res = self; memset(&self, 0, sizeof(LDKBolt11ParseError)); return res; } + ~Bolt11ParseError() { Bolt11ParseError_free(self); } + Bolt11ParseError& operator=(Bolt11ParseError&& o) { Bolt11ParseError_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11ParseError)); return *this; } + LDKBolt11ParseError* operator &() { return &self; } + LDKBolt11ParseError* operator ->() { return &self; } + const LDKBolt11ParseError* operator &() const { return &self; } + const LDKBolt11ParseError* operator ->() const { return &self; } }; -class UpdateFee { +class ParseOrSemanticError { private: - LDKUpdateFee self; + LDKParseOrSemanticError self; public: - UpdateFee(const UpdateFee&) = delete; - UpdateFee(UpdateFee&& o) : self(o.self) { memset(&o, 0, sizeof(UpdateFee)); } - UpdateFee(LDKUpdateFee&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUpdateFee)); } - operator LDKUpdateFee() && { LDKUpdateFee res = self; memset(&self, 0, sizeof(LDKUpdateFee)); return res; } - ~UpdateFee() { UpdateFee_free(self); } - UpdateFee& operator=(UpdateFee&& o) { UpdateFee_free(self); self = o.self; memset(&o, 0, sizeof(UpdateFee)); return *this; } - LDKUpdateFee* operator &() { return &self; } - LDKUpdateFee* operator ->() { return &self; } - const LDKUpdateFee* operator &() const { return &self; } - const LDKUpdateFee* operator ->() const { return &self; } + ParseOrSemanticError(const ParseOrSemanticError&) = delete; + ParseOrSemanticError(ParseOrSemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseOrSemanticError)); } + ParseOrSemanticError(LDKParseOrSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseOrSemanticError)); } + operator LDKParseOrSemanticError() && { LDKParseOrSemanticError res = self; memset(&self, 0, sizeof(LDKParseOrSemanticError)); return res; } + ~ParseOrSemanticError() { ParseOrSemanticError_free(self); } + ParseOrSemanticError& operator=(ParseOrSemanticError&& o) { ParseOrSemanticError_free(self); self = o.self; memset(&o, 0, sizeof(ParseOrSemanticError)); return *this; } + LDKParseOrSemanticError* operator &() { return &self; } + LDKParseOrSemanticError* operator ->() { return &self; } + const LDKParseOrSemanticError* operator &() const { return &self; } + const LDKParseOrSemanticError* operator ->() const { return &self; } }; -class DataLossProtect { +class Bolt11Invoice { +private: + LDKBolt11Invoice self; +public: + Bolt11Invoice(const Bolt11Invoice&) = delete; + Bolt11Invoice(Bolt11Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11Invoice)); } + Bolt11Invoice(LDKBolt11Invoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11Invoice)); } + operator LDKBolt11Invoice() && { LDKBolt11Invoice res = self; memset(&self, 0, sizeof(LDKBolt11Invoice)); return res; } + ~Bolt11Invoice() { Bolt11Invoice_free(self); } + Bolt11Invoice& operator=(Bolt11Invoice&& o) { Bolt11Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11Invoice)); return *this; } + LDKBolt11Invoice* operator &() { return &self; } + LDKBolt11Invoice* operator ->() { return &self; } + const LDKBolt11Invoice* operator &() const { return &self; } + const LDKBolt11Invoice* operator ->() const { return &self; } +}; +class SignedRawBolt11Invoice { +private: + LDKSignedRawBolt11Invoice self; +public: + SignedRawBolt11Invoice(const SignedRawBolt11Invoice&) = delete; + SignedRawBolt11Invoice(SignedRawBolt11Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(SignedRawBolt11Invoice)); } + SignedRawBolt11Invoice(LDKSignedRawBolt11Invoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignedRawBolt11Invoice)); } + operator LDKSignedRawBolt11Invoice() && { LDKSignedRawBolt11Invoice res = self; memset(&self, 0, sizeof(LDKSignedRawBolt11Invoice)); return res; } + ~SignedRawBolt11Invoice() { SignedRawBolt11Invoice_free(self); } + SignedRawBolt11Invoice& operator=(SignedRawBolt11Invoice&& o) { SignedRawBolt11Invoice_free(self); self = o.self; memset(&o, 0, sizeof(SignedRawBolt11Invoice)); return *this; } + LDKSignedRawBolt11Invoice* operator &() { return &self; } + LDKSignedRawBolt11Invoice* operator ->() { return &self; } + const LDKSignedRawBolt11Invoice* operator &() const { return &self; } + const LDKSignedRawBolt11Invoice* operator ->() const { return &self; } +}; +class RawBolt11Invoice { +private: + LDKRawBolt11Invoice self; +public: + RawBolt11Invoice(const RawBolt11Invoice&) = delete; + RawBolt11Invoice(RawBolt11Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(RawBolt11Invoice)); } + RawBolt11Invoice(LDKRawBolt11Invoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawBolt11Invoice)); } + operator LDKRawBolt11Invoice() && { LDKRawBolt11Invoice res = self; memset(&self, 0, sizeof(LDKRawBolt11Invoice)); return res; } + ~RawBolt11Invoice() { RawBolt11Invoice_free(self); } + RawBolt11Invoice& operator=(RawBolt11Invoice&& o) { RawBolt11Invoice_free(self); self = o.self; memset(&o, 0, sizeof(RawBolt11Invoice)); return *this; } + LDKRawBolt11Invoice* operator &() { return &self; } + LDKRawBolt11Invoice* operator ->() { return &self; } + const LDKRawBolt11Invoice* operator &() const { return &self; } + const LDKRawBolt11Invoice* operator ->() const { return &self; } +}; +class RawDataPart { private: - LDKDataLossProtect self; + LDKRawDataPart self; public: - DataLossProtect(const DataLossProtect&) = delete; - DataLossProtect(DataLossProtect&& o) : self(o.self) { memset(&o, 0, sizeof(DataLossProtect)); } - DataLossProtect(LDKDataLossProtect&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDataLossProtect)); } - operator LDKDataLossProtect() && { LDKDataLossProtect res = self; memset(&self, 0, sizeof(LDKDataLossProtect)); return res; } - ~DataLossProtect() { DataLossProtect_free(self); } - DataLossProtect& operator=(DataLossProtect&& o) { DataLossProtect_free(self); self = o.self; memset(&o, 0, sizeof(DataLossProtect)); return *this; } - LDKDataLossProtect* operator &() { return &self; } - LDKDataLossProtect* operator ->() { return &self; } - const LDKDataLossProtect* operator &() const { return &self; } - const LDKDataLossProtect* operator ->() const { return &self; } + RawDataPart(const RawDataPart&) = delete; + RawDataPart(RawDataPart&& o) : self(o.self) { memset(&o, 0, sizeof(RawDataPart)); } + RawDataPart(LDKRawDataPart&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawDataPart)); } + operator LDKRawDataPart() && { LDKRawDataPart res = self; memset(&self, 0, sizeof(LDKRawDataPart)); return res; } + ~RawDataPart() { RawDataPart_free(self); } + RawDataPart& operator=(RawDataPart&& o) { RawDataPart_free(self); self = o.self; memset(&o, 0, sizeof(RawDataPart)); return *this; } + LDKRawDataPart* operator &() { return &self; } + LDKRawDataPart* operator ->() { return &self; } + const LDKRawDataPart* operator &() const { return &self; } + const LDKRawDataPart* operator ->() const { return &self; } }; -class ChannelReestablish { +class PositiveTimestamp { private: - LDKChannelReestablish self; + LDKPositiveTimestamp self; public: - ChannelReestablish(const ChannelReestablish&) = delete; - ChannelReestablish(ChannelReestablish&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelReestablish)); } - ChannelReestablish(LDKChannelReestablish&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelReestablish)); } - operator LDKChannelReestablish() && { LDKChannelReestablish res = self; memset(&self, 0, sizeof(LDKChannelReestablish)); return res; } - ~ChannelReestablish() { ChannelReestablish_free(self); } - ChannelReestablish& operator=(ChannelReestablish&& o) { ChannelReestablish_free(self); self = o.self; memset(&o, 0, sizeof(ChannelReestablish)); return *this; } - LDKChannelReestablish* operator &() { return &self; } - LDKChannelReestablish* operator ->() { return &self; } - const LDKChannelReestablish* operator &() const { return &self; } - const LDKChannelReestablish* operator ->() const { return &self; } + PositiveTimestamp(const PositiveTimestamp&) = delete; + PositiveTimestamp(PositiveTimestamp&& o) : self(o.self) { memset(&o, 0, sizeof(PositiveTimestamp)); } + PositiveTimestamp(LDKPositiveTimestamp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPositiveTimestamp)); } + operator LDKPositiveTimestamp() && { LDKPositiveTimestamp res = self; memset(&self, 0, sizeof(LDKPositiveTimestamp)); return res; } + ~PositiveTimestamp() { PositiveTimestamp_free(self); } + PositiveTimestamp& operator=(PositiveTimestamp&& o) { PositiveTimestamp_free(self); self = o.self; memset(&o, 0, sizeof(PositiveTimestamp)); return *this; } + LDKPositiveTimestamp* operator &() { return &self; } + LDKPositiveTimestamp* operator ->() { return &self; } + const LDKPositiveTimestamp* operator &() const { return &self; } + const LDKPositiveTimestamp* operator ->() const { return &self; } }; -class AnnouncementSignatures { +class SiPrefix { private: - LDKAnnouncementSignatures self; + LDKSiPrefix self; public: - AnnouncementSignatures(const AnnouncementSignatures&) = delete; - AnnouncementSignatures(AnnouncementSignatures&& o) : self(o.self) { memset(&o, 0, sizeof(AnnouncementSignatures)); } - AnnouncementSignatures(LDKAnnouncementSignatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAnnouncementSignatures)); } - operator LDKAnnouncementSignatures() && { LDKAnnouncementSignatures res = self; memset(&self, 0, sizeof(LDKAnnouncementSignatures)); return res; } - ~AnnouncementSignatures() { AnnouncementSignatures_free(self); } - AnnouncementSignatures& operator=(AnnouncementSignatures&& o) { AnnouncementSignatures_free(self); self = o.self; memset(&o, 0, sizeof(AnnouncementSignatures)); return *this; } - LDKAnnouncementSignatures* operator &() { return &self; } - LDKAnnouncementSignatures* operator ->() { return &self; } - const LDKAnnouncementSignatures* operator &() const { return &self; } - const LDKAnnouncementSignatures* operator ->() const { return &self; } + SiPrefix(const SiPrefix&) = delete; + SiPrefix(SiPrefix&& o) : self(o.self) { memset(&o, 0, sizeof(SiPrefix)); } + SiPrefix(LDKSiPrefix&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSiPrefix)); } + operator LDKSiPrefix() && { LDKSiPrefix res = self; memset(&self, 0, sizeof(LDKSiPrefix)); return res; } + SiPrefix& operator=(SiPrefix&& o) { self = o.self; memset(&o, 0, sizeof(SiPrefix)); return *this; } + LDKSiPrefix* operator &() { return &self; } + LDKSiPrefix* operator ->() { return &self; } + const LDKSiPrefix* operator &() const { return &self; } + const LDKSiPrefix* operator ->() const { return &self; } }; -class NetAddress { +class Currency { private: - LDKNetAddress self; + LDKCurrency self; public: - NetAddress(const NetAddress&) = delete; - NetAddress(NetAddress&& o) : self(o.self) { memset(&o, 0, sizeof(NetAddress)); } - NetAddress(LDKNetAddress&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetAddress)); } - operator LDKNetAddress() && { LDKNetAddress res = self; memset(&self, 0, sizeof(LDKNetAddress)); return res; } - ~NetAddress() { NetAddress_free(self); } - NetAddress& operator=(NetAddress&& o) { NetAddress_free(self); self = o.self; memset(&o, 0, sizeof(NetAddress)); return *this; } - LDKNetAddress* operator &() { return &self; } - LDKNetAddress* operator ->() { return &self; } - const LDKNetAddress* operator &() const { return &self; } - const LDKNetAddress* operator ->() const { return &self; } + Currency(const Currency&) = delete; + Currency(Currency&& o) : self(o.self) { memset(&o, 0, sizeof(Currency)); } + Currency(LDKCurrency&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCurrency)); } + operator LDKCurrency() && { LDKCurrency res = self; memset(&self, 0, sizeof(LDKCurrency)); return res; } + Currency& operator=(Currency&& o) { self = o.self; memset(&o, 0, sizeof(Currency)); return *this; } + LDKCurrency* operator &() { return &self; } + LDKCurrency* operator ->() { return &self; } + const LDKCurrency* operator &() const { return &self; } + const LDKCurrency* operator ->() const { return &self; } }; -class UnsignedGossipMessage { +class Sha256 { private: - LDKUnsignedGossipMessage self; + LDKSha256 self; public: - UnsignedGossipMessage(const UnsignedGossipMessage&) = delete; - UnsignedGossipMessage(UnsignedGossipMessage&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedGossipMessage)); } - UnsignedGossipMessage(LDKUnsignedGossipMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedGossipMessage)); } - operator LDKUnsignedGossipMessage() && { LDKUnsignedGossipMessage res = self; memset(&self, 0, sizeof(LDKUnsignedGossipMessage)); return res; } - ~UnsignedGossipMessage() { UnsignedGossipMessage_free(self); } - UnsignedGossipMessage& operator=(UnsignedGossipMessage&& o) { UnsignedGossipMessage_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedGossipMessage)); return *this; } - LDKUnsignedGossipMessage* operator &() { return &self; } - LDKUnsignedGossipMessage* operator ->() { return &self; } - const LDKUnsignedGossipMessage* operator &() const { return &self; } - const LDKUnsignedGossipMessage* operator ->() const { return &self; } + Sha256(const Sha256&) = delete; + Sha256(Sha256&& o) : self(o.self) { memset(&o, 0, sizeof(Sha256)); } + Sha256(LDKSha256&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSha256)); } + operator LDKSha256() && { LDKSha256 res = self; memset(&self, 0, sizeof(LDKSha256)); return res; } + ~Sha256() { Sha256_free(self); } + Sha256& operator=(Sha256&& o) { Sha256_free(self); self = o.self; memset(&o, 0, sizeof(Sha256)); return *this; } + LDKSha256* operator &() { return &self; } + LDKSha256* operator ->() { return &self; } + const LDKSha256* operator &() const { return &self; } + const LDKSha256* operator ->() const { return &self; } }; -class UnsignedNodeAnnouncement { +class Description { private: - LDKUnsignedNodeAnnouncement self; + LDKDescription self; public: - UnsignedNodeAnnouncement(const UnsignedNodeAnnouncement&) = delete; - UnsignedNodeAnnouncement(UnsignedNodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedNodeAnnouncement)); } - UnsignedNodeAnnouncement(LDKUnsignedNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedNodeAnnouncement)); } - operator LDKUnsignedNodeAnnouncement() && { LDKUnsignedNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedNodeAnnouncement)); return res; } - ~UnsignedNodeAnnouncement() { UnsignedNodeAnnouncement_free(self); } - UnsignedNodeAnnouncement& operator=(UnsignedNodeAnnouncement&& o) { UnsignedNodeAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedNodeAnnouncement)); return *this; } - LDKUnsignedNodeAnnouncement* operator &() { return &self; } - LDKUnsignedNodeAnnouncement* operator ->() { return &self; } - const LDKUnsignedNodeAnnouncement* operator &() const { return &self; } - const LDKUnsignedNodeAnnouncement* operator ->() const { return &self; } + Description(const Description&) = delete; + Description(Description&& o) : self(o.self) { memset(&o, 0, sizeof(Description)); } + Description(LDKDescription&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDescription)); } + operator LDKDescription() && { LDKDescription res = self; memset(&self, 0, sizeof(LDKDescription)); return res; } + ~Description() { Description_free(self); } + Description& operator=(Description&& o) { Description_free(self); self = o.self; memset(&o, 0, sizeof(Description)); return *this; } + LDKDescription* operator &() { return &self; } + LDKDescription* operator ->() { return &self; } + const LDKDescription* operator &() const { return &self; } + const LDKDescription* operator ->() const { return &self; } }; -class NodeAnnouncement { +class PayeePubKey { private: - LDKNodeAnnouncement self; + LDKPayeePubKey self; public: - NodeAnnouncement(const NodeAnnouncement&) = delete; - NodeAnnouncement(NodeAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncement)); } - NodeAnnouncement(LDKNodeAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncement)); } - operator LDKNodeAnnouncement() && { LDKNodeAnnouncement res = self; memset(&self, 0, sizeof(LDKNodeAnnouncement)); return res; } - ~NodeAnnouncement() { NodeAnnouncement_free(self); } - NodeAnnouncement& operator=(NodeAnnouncement&& o) { NodeAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(NodeAnnouncement)); return *this; } - LDKNodeAnnouncement* operator &() { return &self; } - LDKNodeAnnouncement* operator ->() { return &self; } - const LDKNodeAnnouncement* operator &() const { return &self; } - const LDKNodeAnnouncement* operator ->() const { return &self; } + PayeePubKey(const PayeePubKey&) = delete; + PayeePubKey(PayeePubKey&& o) : self(o.self) { memset(&o, 0, sizeof(PayeePubKey)); } + PayeePubKey(LDKPayeePubKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayeePubKey)); } + operator LDKPayeePubKey() && { LDKPayeePubKey res = self; memset(&self, 0, sizeof(LDKPayeePubKey)); return res; } + ~PayeePubKey() { PayeePubKey_free(self); } + PayeePubKey& operator=(PayeePubKey&& o) { PayeePubKey_free(self); self = o.self; memset(&o, 0, sizeof(PayeePubKey)); return *this; } + LDKPayeePubKey* operator &() { return &self; } + LDKPayeePubKey* operator ->() { return &self; } + const LDKPayeePubKey* operator &() const { return &self; } + const LDKPayeePubKey* operator ->() const { return &self; } }; -class UnsignedChannelAnnouncement { +class ExpiryTime { private: - LDKUnsignedChannelAnnouncement self; + LDKExpiryTime self; public: - UnsignedChannelAnnouncement(const UnsignedChannelAnnouncement&) = delete; - UnsignedChannelAnnouncement(UnsignedChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelAnnouncement)); } - UnsignedChannelAnnouncement(LDKUnsignedChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelAnnouncement)); } - operator LDKUnsignedChannelAnnouncement() && { LDKUnsignedChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKUnsignedChannelAnnouncement)); return res; } - ~UnsignedChannelAnnouncement() { UnsignedChannelAnnouncement_free(self); } - UnsignedChannelAnnouncement& operator=(UnsignedChannelAnnouncement&& o) { UnsignedChannelAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedChannelAnnouncement)); return *this; } - LDKUnsignedChannelAnnouncement* operator &() { return &self; } - LDKUnsignedChannelAnnouncement* operator ->() { return &self; } - const LDKUnsignedChannelAnnouncement* operator &() const { return &self; } - const LDKUnsignedChannelAnnouncement* operator ->() const { return &self; } + ExpiryTime(const ExpiryTime&) = delete; + ExpiryTime(ExpiryTime&& o) : self(o.self) { memset(&o, 0, sizeof(ExpiryTime)); } + ExpiryTime(LDKExpiryTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpiryTime)); } + operator LDKExpiryTime() && { LDKExpiryTime res = self; memset(&self, 0, sizeof(LDKExpiryTime)); return res; } + ~ExpiryTime() { ExpiryTime_free(self); } + ExpiryTime& operator=(ExpiryTime&& o) { ExpiryTime_free(self); self = o.self; memset(&o, 0, sizeof(ExpiryTime)); return *this; } + LDKExpiryTime* operator &() { return &self; } + LDKExpiryTime* operator ->() { return &self; } + const LDKExpiryTime* operator &() const { return &self; } + const LDKExpiryTime* operator ->() const { return &self; } }; -class ChannelAnnouncement { +class MinFinalCltvExpiryDelta { private: - LDKChannelAnnouncement self; + LDKMinFinalCltvExpiryDelta self; public: - ChannelAnnouncement(const ChannelAnnouncement&) = delete; - ChannelAnnouncement(ChannelAnnouncement&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelAnnouncement)); } - ChannelAnnouncement(LDKChannelAnnouncement&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelAnnouncement)); } - operator LDKChannelAnnouncement() && { LDKChannelAnnouncement res = self; memset(&self, 0, sizeof(LDKChannelAnnouncement)); return res; } - ~ChannelAnnouncement() { ChannelAnnouncement_free(self); } - ChannelAnnouncement& operator=(ChannelAnnouncement&& o) { ChannelAnnouncement_free(self); self = o.self; memset(&o, 0, sizeof(ChannelAnnouncement)); return *this; } - LDKChannelAnnouncement* operator &() { return &self; } - LDKChannelAnnouncement* operator ->() { return &self; } - const LDKChannelAnnouncement* operator &() const { return &self; } - const LDKChannelAnnouncement* operator ->() const { return &self; } + MinFinalCltvExpiryDelta(const MinFinalCltvExpiryDelta&) = delete; + MinFinalCltvExpiryDelta(MinFinalCltvExpiryDelta&& o) : self(o.self) { memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); } + MinFinalCltvExpiryDelta(LDKMinFinalCltvExpiryDelta&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); } + operator LDKMinFinalCltvExpiryDelta() && { LDKMinFinalCltvExpiryDelta res = self; memset(&self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); return res; } + ~MinFinalCltvExpiryDelta() { MinFinalCltvExpiryDelta_free(self); } + MinFinalCltvExpiryDelta& operator=(MinFinalCltvExpiryDelta&& o) { MinFinalCltvExpiryDelta_free(self); self = o.self; memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); return *this; } + LDKMinFinalCltvExpiryDelta* operator &() { return &self; } + LDKMinFinalCltvExpiryDelta* operator ->() { return &self; } + const LDKMinFinalCltvExpiryDelta* operator &() const { return &self; } + const LDKMinFinalCltvExpiryDelta* operator ->() const { return &self; } }; -class UnsignedChannelUpdate { +class Fallback { private: - LDKUnsignedChannelUpdate self; + LDKFallback self; public: - UnsignedChannelUpdate(const UnsignedChannelUpdate&) = delete; - UnsignedChannelUpdate(UnsignedChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedChannelUpdate)); } - UnsignedChannelUpdate(LDKUnsignedChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedChannelUpdate)); } - operator LDKUnsignedChannelUpdate() && { LDKUnsignedChannelUpdate res = self; memset(&self, 0, sizeof(LDKUnsignedChannelUpdate)); return res; } - ~UnsignedChannelUpdate() { UnsignedChannelUpdate_free(self); } - UnsignedChannelUpdate& operator=(UnsignedChannelUpdate&& o) { UnsignedChannelUpdate_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedChannelUpdate)); return *this; } - LDKUnsignedChannelUpdate* operator &() { return &self; } - LDKUnsignedChannelUpdate* operator ->() { return &self; } - const LDKUnsignedChannelUpdate* operator &() const { return &self; } - const LDKUnsignedChannelUpdate* operator ->() const { return &self; } + Fallback(const Fallback&) = delete; + Fallback(Fallback&& o) : self(o.self) { memset(&o, 0, sizeof(Fallback)); } + Fallback(LDKFallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFallback)); } + operator LDKFallback() && { LDKFallback res = self; memset(&self, 0, sizeof(LDKFallback)); return res; } + ~Fallback() { Fallback_free(self); } + Fallback& operator=(Fallback&& o) { Fallback_free(self); self = o.self; memset(&o, 0, sizeof(Fallback)); return *this; } + LDKFallback* operator &() { return &self; } + LDKFallback* operator ->() { return &self; } + const LDKFallback* operator &() const { return &self; } + const LDKFallback* operator ->() const { return &self; } }; -class ChannelUpdate { +class Bolt11InvoiceSignature { private: - LDKChannelUpdate self; + LDKBolt11InvoiceSignature self; public: - ChannelUpdate(const ChannelUpdate&) = delete; - ChannelUpdate(ChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUpdate)); } - ChannelUpdate(LDKChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUpdate)); } - operator LDKChannelUpdate() && { LDKChannelUpdate res = self; memset(&self, 0, sizeof(LDKChannelUpdate)); return res; } - ~ChannelUpdate() { ChannelUpdate_free(self); } - ChannelUpdate& operator=(ChannelUpdate&& o) { ChannelUpdate_free(self); self = o.self; memset(&o, 0, sizeof(ChannelUpdate)); return *this; } - LDKChannelUpdate* operator &() { return &self; } - LDKChannelUpdate* operator ->() { return &self; } - const LDKChannelUpdate* operator &() const { return &self; } - const LDKChannelUpdate* operator ->() const { return &self; } + Bolt11InvoiceSignature(const Bolt11InvoiceSignature&) = delete; + Bolt11InvoiceSignature(Bolt11InvoiceSignature&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11InvoiceSignature)); } + Bolt11InvoiceSignature(LDKBolt11InvoiceSignature&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11InvoiceSignature)); } + operator LDKBolt11InvoiceSignature() && { LDKBolt11InvoiceSignature res = self; memset(&self, 0, sizeof(LDKBolt11InvoiceSignature)); return res; } + ~Bolt11InvoiceSignature() { Bolt11InvoiceSignature_free(self); } + Bolt11InvoiceSignature& operator=(Bolt11InvoiceSignature&& o) { Bolt11InvoiceSignature_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11InvoiceSignature)); return *this; } + LDKBolt11InvoiceSignature* operator &() { return &self; } + LDKBolt11InvoiceSignature* operator ->() { return &self; } + const LDKBolt11InvoiceSignature* operator &() const { return &self; } + const LDKBolt11InvoiceSignature* operator ->() const { return &self; } }; -class QueryChannelRange { +class PrivateRoute { private: - LDKQueryChannelRange self; + LDKPrivateRoute self; public: - QueryChannelRange(const QueryChannelRange&) = delete; - QueryChannelRange(QueryChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(QueryChannelRange)); } - QueryChannelRange(LDKQueryChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryChannelRange)); } - operator LDKQueryChannelRange() && { LDKQueryChannelRange res = self; memset(&self, 0, sizeof(LDKQueryChannelRange)); return res; } - ~QueryChannelRange() { QueryChannelRange_free(self); } - QueryChannelRange& operator=(QueryChannelRange&& o) { QueryChannelRange_free(self); self = o.self; memset(&o, 0, sizeof(QueryChannelRange)); return *this; } - LDKQueryChannelRange* operator &() { return &self; } - LDKQueryChannelRange* operator ->() { return &self; } - const LDKQueryChannelRange* operator &() const { return &self; } - const LDKQueryChannelRange* operator ->() const { return &self; } + PrivateRoute(const PrivateRoute&) = delete; + PrivateRoute(PrivateRoute&& o) : self(o.self) { memset(&o, 0, sizeof(PrivateRoute)); } + PrivateRoute(LDKPrivateRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrivateRoute)); } + operator LDKPrivateRoute() && { LDKPrivateRoute res = self; memset(&self, 0, sizeof(LDKPrivateRoute)); return res; } + ~PrivateRoute() { PrivateRoute_free(self); } + PrivateRoute& operator=(PrivateRoute&& o) { PrivateRoute_free(self); self = o.self; memset(&o, 0, sizeof(PrivateRoute)); return *this; } + LDKPrivateRoute* operator &() { return &self; } + LDKPrivateRoute* operator ->() { return &self; } + const LDKPrivateRoute* operator &() const { return &self; } + const LDKPrivateRoute* operator ->() const { return &self; } }; -class ReplyChannelRange { +class CreationError { private: - LDKReplyChannelRange self; + LDKCreationError self; public: - ReplyChannelRange(const ReplyChannelRange&) = delete; - ReplyChannelRange(ReplyChannelRange&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyChannelRange)); } - ReplyChannelRange(LDKReplyChannelRange&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyChannelRange)); } - operator LDKReplyChannelRange() && { LDKReplyChannelRange res = self; memset(&self, 0, sizeof(LDKReplyChannelRange)); return res; } - ~ReplyChannelRange() { ReplyChannelRange_free(self); } - ReplyChannelRange& operator=(ReplyChannelRange&& o) { ReplyChannelRange_free(self); self = o.self; memset(&o, 0, sizeof(ReplyChannelRange)); return *this; } - LDKReplyChannelRange* operator &() { return &self; } - LDKReplyChannelRange* operator ->() { return &self; } - const LDKReplyChannelRange* operator &() const { return &self; } - const LDKReplyChannelRange* operator ->() const { return &self; } + CreationError(const CreationError&) = delete; + CreationError(CreationError&& o) : self(o.self) { memset(&o, 0, sizeof(CreationError)); } + CreationError(LDKCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCreationError)); } + operator LDKCreationError() && { LDKCreationError res = self; memset(&self, 0, sizeof(LDKCreationError)); return res; } + CreationError& operator=(CreationError&& o) { self = o.self; memset(&o, 0, sizeof(CreationError)); return *this; } + LDKCreationError* operator &() { return &self; } + LDKCreationError* operator ->() { return &self; } + const LDKCreationError* operator &() const { return &self; } + const LDKCreationError* operator ->() const { return &self; } }; -class QueryShortChannelIds { +class Bolt11SemanticError { private: - LDKQueryShortChannelIds self; + LDKBolt11SemanticError self; public: - QueryShortChannelIds(const QueryShortChannelIds&) = delete; - QueryShortChannelIds(QueryShortChannelIds&& o) : self(o.self) { memset(&o, 0, sizeof(QueryShortChannelIds)); } - QueryShortChannelIds(LDKQueryShortChannelIds&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQueryShortChannelIds)); } - operator LDKQueryShortChannelIds() && { LDKQueryShortChannelIds res = self; memset(&self, 0, sizeof(LDKQueryShortChannelIds)); return res; } - ~QueryShortChannelIds() { QueryShortChannelIds_free(self); } - QueryShortChannelIds& operator=(QueryShortChannelIds&& o) { QueryShortChannelIds_free(self); self = o.self; memset(&o, 0, sizeof(QueryShortChannelIds)); return *this; } - LDKQueryShortChannelIds* operator &() { return &self; } - LDKQueryShortChannelIds* operator ->() { return &self; } - const LDKQueryShortChannelIds* operator &() const { return &self; } - const LDKQueryShortChannelIds* operator ->() const { return &self; } + Bolt11SemanticError(const Bolt11SemanticError&) = delete; + Bolt11SemanticError(Bolt11SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11SemanticError)); } + Bolt11SemanticError(LDKBolt11SemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11SemanticError)); } + operator LDKBolt11SemanticError() && { LDKBolt11SemanticError res = self; memset(&self, 0, sizeof(LDKBolt11SemanticError)); return res; } + Bolt11SemanticError& operator=(Bolt11SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(Bolt11SemanticError)); return *this; } + LDKBolt11SemanticError* operator &() { return &self; } + LDKBolt11SemanticError* operator ->() { return &self; } + const LDKBolt11SemanticError* operator &() const { return &self; } + const LDKBolt11SemanticError* operator ->() const { return &self; } }; -class ReplyShortChannelIdsEnd { +class SignOrCreationError { private: - LDKReplyShortChannelIdsEnd self; + LDKSignOrCreationError self; public: - ReplyShortChannelIdsEnd(const ReplyShortChannelIdsEnd&) = delete; - ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd&& o) : self(o.self) { memset(&o, 0, sizeof(ReplyShortChannelIdsEnd)); } - ReplyShortChannelIdsEnd(LDKReplyShortChannelIdsEnd&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplyShortChannelIdsEnd)); } - operator LDKReplyShortChannelIdsEnd() && { LDKReplyShortChannelIdsEnd res = self; memset(&self, 0, sizeof(LDKReplyShortChannelIdsEnd)); return res; } - ~ReplyShortChannelIdsEnd() { ReplyShortChannelIdsEnd_free(self); } - ReplyShortChannelIdsEnd& operator=(ReplyShortChannelIdsEnd&& o) { ReplyShortChannelIdsEnd_free(self); self = o.self; memset(&o, 0, sizeof(ReplyShortChannelIdsEnd)); return *this; } - LDKReplyShortChannelIdsEnd* operator &() { return &self; } - LDKReplyShortChannelIdsEnd* operator ->() { return &self; } - const LDKReplyShortChannelIdsEnd* operator &() const { return &self; } - const LDKReplyShortChannelIdsEnd* operator ->() const { return &self; } + SignOrCreationError(const SignOrCreationError&) = delete; + SignOrCreationError(SignOrCreationError&& o) : self(o.self) { memset(&o, 0, sizeof(SignOrCreationError)); } + SignOrCreationError(LDKSignOrCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignOrCreationError)); } + operator LDKSignOrCreationError() && { LDKSignOrCreationError res = self; memset(&self, 0, sizeof(LDKSignOrCreationError)); return res; } + ~SignOrCreationError() { SignOrCreationError_free(self); } + SignOrCreationError& operator=(SignOrCreationError&& o) { SignOrCreationError_free(self); self = o.self; memset(&o, 0, sizeof(SignOrCreationError)); return *this; } + LDKSignOrCreationError* operator &() { return &self; } + LDKSignOrCreationError* operator ->() { return &self; } + const LDKSignOrCreationError* operator &() const { return &self; } + const LDKSignOrCreationError* operator ->() const { return &self; } }; -class GossipTimestampFilter { +class OutPoint { private: - LDKGossipTimestampFilter self; + LDKOutPoint self; public: - GossipTimestampFilter(const GossipTimestampFilter&) = delete; - GossipTimestampFilter(GossipTimestampFilter&& o) : self(o.self) { memset(&o, 0, sizeof(GossipTimestampFilter)); } - GossipTimestampFilter(LDKGossipTimestampFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGossipTimestampFilter)); } - operator LDKGossipTimestampFilter() && { LDKGossipTimestampFilter res = self; memset(&self, 0, sizeof(LDKGossipTimestampFilter)); return res; } - ~GossipTimestampFilter() { GossipTimestampFilter_free(self); } - GossipTimestampFilter& operator=(GossipTimestampFilter&& o) { GossipTimestampFilter_free(self); self = o.self; memset(&o, 0, sizeof(GossipTimestampFilter)); return *this; } - LDKGossipTimestampFilter* operator &() { return &self; } - LDKGossipTimestampFilter* operator ->() { return &self; } - const LDKGossipTimestampFilter* operator &() const { return &self; } - const LDKGossipTimestampFilter* operator ->() const { return &self; } + OutPoint(const OutPoint&) = delete; + OutPoint(OutPoint&& o) : self(o.self) { memset(&o, 0, sizeof(OutPoint)); } + OutPoint(LDKOutPoint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutPoint)); } + operator LDKOutPoint() && { LDKOutPoint res = self; memset(&self, 0, sizeof(LDKOutPoint)); return res; } + ~OutPoint() { OutPoint_free(self); } + OutPoint& operator=(OutPoint&& o) { OutPoint_free(self); self = o.self; memset(&o, 0, sizeof(OutPoint)); return *this; } + LDKOutPoint* operator &() { return &self; } + LDKOutPoint* operator ->() { return &self; } + const LDKOutPoint* operator &() const { return &self; } + const LDKOutPoint* operator ->() const { return &self; } }; -class ErrorAction { +class BigSize { private: - LDKErrorAction self; + LDKBigSize self; public: - ErrorAction(const ErrorAction&) = delete; - ErrorAction(ErrorAction&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorAction)); } - ErrorAction(LDKErrorAction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorAction)); } - operator LDKErrorAction() && { LDKErrorAction res = self; memset(&self, 0, sizeof(LDKErrorAction)); return res; } - ~ErrorAction() { ErrorAction_free(self); } - ErrorAction& operator=(ErrorAction&& o) { ErrorAction_free(self); self = o.self; memset(&o, 0, sizeof(ErrorAction)); return *this; } - LDKErrorAction* operator &() { return &self; } - LDKErrorAction* operator ->() { return &self; } - const LDKErrorAction* operator &() const { return &self; } - const LDKErrorAction* operator ->() const { return &self; } + BigSize(const BigSize&) = delete; + BigSize(BigSize&& o) : self(o.self) { memset(&o, 0, sizeof(BigSize)); } + BigSize(LDKBigSize&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBigSize)); } + operator LDKBigSize() && { LDKBigSize res = self; memset(&self, 0, sizeof(LDKBigSize)); return res; } + ~BigSize() { BigSize_free(self); } + BigSize& operator=(BigSize&& o) { BigSize_free(self); self = o.self; memset(&o, 0, sizeof(BigSize)); return *this; } + LDKBigSize* operator &() { return &self; } + LDKBigSize* operator ->() { return &self; } + const LDKBigSize* operator &() const { return &self; } + const LDKBigSize* operator ->() const { return &self; } +}; +class Hostname { +private: + LDKHostname self; +public: + Hostname(const Hostname&) = delete; + Hostname(Hostname&& o) : self(o.self) { memset(&o, 0, sizeof(Hostname)); } + Hostname(LDKHostname&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHostname)); } + operator LDKHostname() && { LDKHostname res = self; memset(&self, 0, sizeof(LDKHostname)); return res; } + ~Hostname() { Hostname_free(self); } + Hostname& operator=(Hostname&& o) { Hostname_free(self); self = o.self; memset(&o, 0, sizeof(Hostname)); return *this; } + LDKHostname* operator &() { return &self; } + LDKHostname* operator ->() { return &self; } + const LDKHostname* operator &() const { return &self; } + const LDKHostname* operator ->() const { return &self; } }; -class LightningError { +class TransactionU16LenLimited { private: - LDKLightningError self; + LDKTransactionU16LenLimited self; public: - LightningError(const LightningError&) = delete; - LightningError(LightningError&& o) : self(o.self) { memset(&o, 0, sizeof(LightningError)); } - LightningError(LDKLightningError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLightningError)); } - operator LDKLightningError() && { LDKLightningError res = self; memset(&self, 0, sizeof(LDKLightningError)); return res; } - ~LightningError() { LightningError_free(self); } - LightningError& operator=(LightningError&& o) { LightningError_free(self); self = o.self; memset(&o, 0, sizeof(LightningError)); return *this; } - LDKLightningError* operator &() { return &self; } - LDKLightningError* operator ->() { return &self; } - const LDKLightningError* operator &() const { return &self; } - const LDKLightningError* operator ->() const { return &self; } + TransactionU16LenLimited(const TransactionU16LenLimited&) = delete; + TransactionU16LenLimited(TransactionU16LenLimited&& o) : self(o.self) { memset(&o, 0, sizeof(TransactionU16LenLimited)); } + TransactionU16LenLimited(LDKTransactionU16LenLimited&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTransactionU16LenLimited)); } + operator LDKTransactionU16LenLimited() && { LDKTransactionU16LenLimited res = self; memset(&self, 0, sizeof(LDKTransactionU16LenLimited)); return res; } + ~TransactionU16LenLimited() { TransactionU16LenLimited_free(self); } + TransactionU16LenLimited& operator=(TransactionU16LenLimited&& o) { TransactionU16LenLimited_free(self); self = o.self; memset(&o, 0, sizeof(TransactionU16LenLimited)); return *this; } + LDKTransactionU16LenLimited* operator &() { return &self; } + LDKTransactionU16LenLimited* operator ->() { return &self; } + const LDKTransactionU16LenLimited* operator &() const { return &self; } + const LDKTransactionU16LenLimited* operator ->() const { return &self; } }; -class CommitmentUpdate { +class UntrustedString { private: - LDKCommitmentUpdate self; + LDKUntrustedString self; public: - CommitmentUpdate(const CommitmentUpdate&) = delete; - CommitmentUpdate(CommitmentUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentUpdate)); } - CommitmentUpdate(LDKCommitmentUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentUpdate)); } - operator LDKCommitmentUpdate() && { LDKCommitmentUpdate res = self; memset(&self, 0, sizeof(LDKCommitmentUpdate)); return res; } - ~CommitmentUpdate() { CommitmentUpdate_free(self); } - CommitmentUpdate& operator=(CommitmentUpdate&& o) { CommitmentUpdate_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentUpdate)); return *this; } - LDKCommitmentUpdate* operator &() { return &self; } - LDKCommitmentUpdate* operator ->() { return &self; } - const LDKCommitmentUpdate* operator &() const { return &self; } - const LDKCommitmentUpdate* operator ->() const { return &self; } + UntrustedString(const UntrustedString&) = delete; + UntrustedString(UntrustedString&& o) : self(o.self) { memset(&o, 0, sizeof(UntrustedString)); } + UntrustedString(LDKUntrustedString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUntrustedString)); } + operator LDKUntrustedString() && { LDKUntrustedString res = self; memset(&self, 0, sizeof(LDKUntrustedString)); return res; } + ~UntrustedString() { UntrustedString_free(self); } + UntrustedString& operator=(UntrustedString&& o) { UntrustedString_free(self); self = o.self; memset(&o, 0, sizeof(UntrustedString)); return *this; } + LDKUntrustedString* operator &() { return &self; } + LDKUntrustedString* operator ->() { return &self; } + const LDKUntrustedString* operator &() const { return &self; } + const LDKUntrustedString* operator ->() const { return &self; } }; -class ChannelMessageHandler { +class PrintableString { private: - LDKChannelMessageHandler self; + LDKPrintableString self; public: - ChannelMessageHandler(const ChannelMessageHandler&) = delete; - ChannelMessageHandler(ChannelMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMessageHandler)); } - ChannelMessageHandler(LDKChannelMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMessageHandler)); } - operator LDKChannelMessageHandler() && { LDKChannelMessageHandler res = self; memset(&self, 0, sizeof(LDKChannelMessageHandler)); return res; } - ~ChannelMessageHandler() { ChannelMessageHandler_free(self); } - ChannelMessageHandler& operator=(ChannelMessageHandler&& o) { ChannelMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(ChannelMessageHandler)); return *this; } - LDKChannelMessageHandler* operator &() { return &self; } - LDKChannelMessageHandler* operator ->() { return &self; } - const LDKChannelMessageHandler* operator &() const { return &self; } - const LDKChannelMessageHandler* operator ->() const { return &self; } - /** - * Handle an incoming `open_channel` message from the given peer. - */ - inline void handle_open_channel(struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg); - /** - * Handle an incoming `accept_channel` message from the given peer. - */ - inline void handle_accept_channel(struct LDKPublicKey their_node_id, const struct LDKAcceptChannel *NONNULL_PTR msg); - /** - * Handle an incoming `funding_created` message from the given peer. - */ - inline void handle_funding_created(struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg); - /** - * Handle an incoming `funding_signed` message from the given peer. - */ - inline void handle_funding_signed(struct LDKPublicKey their_node_id, const struct LDKFundingSigned *NONNULL_PTR msg); - /** - * Handle an incoming `channel_ready` message from the given peer. - */ - inline void handle_channel_ready(struct LDKPublicKey their_node_id, const struct LDKChannelReady *NONNULL_PTR msg); - /** - * Handle an incoming `shutdown` message from the given peer. - */ - inline void handle_shutdown(struct LDKPublicKey their_node_id, const struct LDKShutdown *NONNULL_PTR msg); - /** - * Handle an incoming `closing_signed` message from the given peer. - */ - inline void handle_closing_signed(struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg); - /** - * Handle an incoming `update_add_htlc` message from the given peer. - */ - inline void handle_update_add_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg); - /** - * Handle an incoming `update_fulfill_htlc` message from the given peer. - */ - inline void handle_update_fulfill_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFulfillHTLC *NONNULL_PTR msg); - /** - * Handle an incoming `update_fail_htlc` message from the given peer. - */ - inline void handle_update_fail_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFailHTLC *NONNULL_PTR msg); - /** - * Handle an incoming `update_fail_malformed_htlc` message from the given peer. - */ - inline void handle_update_fail_malformed_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR msg); - /** - * Handle an incoming `commitment_signed` message from the given peer. - */ - inline void handle_commitment_signed(struct LDKPublicKey their_node_id, const struct LDKCommitmentSigned *NONNULL_PTR msg); - /** - * Handle an incoming `revoke_and_ack` message from the given peer. - */ - inline void handle_revoke_and_ack(struct LDKPublicKey their_node_id, const struct LDKRevokeAndACK *NONNULL_PTR msg); - /** - * Handle an incoming `update_fee` message from the given peer. - */ - inline void handle_update_fee(struct LDKPublicKey their_node_id, const struct LDKUpdateFee *NONNULL_PTR msg); - /** - * Handle an incoming `announcement_signatures` message from the given peer. - */ - inline void handle_announcement_signatures(struct LDKPublicKey their_node_id, const struct LDKAnnouncementSignatures *NONNULL_PTR msg); - /** - * Indicates a connection to the peer failed/an existing connection was lost. - */ - inline void peer_disconnected(struct LDKPublicKey their_node_id); - /** - * Handle a peer reconnecting, possibly generating `channel_reestablish` message(s). - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. - */ - inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); - /** - * Handle an incoming `channel_reestablish` message from the given peer. - */ - inline void handle_channel_reestablish(struct LDKPublicKey their_node_id, const struct LDKChannelReestablish *NONNULL_PTR msg); - /** - * Handle an incoming `channel_update` message from the given peer. - */ - inline void handle_channel_update(struct LDKPublicKey their_node_id, const struct LDKChannelUpdate *NONNULL_PTR msg); - /** - * Handle an incoming `error` message from the given peer. - */ - inline void handle_error(struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg); - /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. - */ - inline LDK::NodeFeatures provided_node_features(); - /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. - * - * Note that this method is called before [`Self::peer_connected`]. - */ - inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); + PrintableString(const PrintableString&) = delete; + PrintableString(PrintableString&& o) : self(o.self) { memset(&o, 0, sizeof(PrintableString)); } + PrintableString(LDKPrintableString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrintableString)); } + operator LDKPrintableString() && { LDKPrintableString res = self; memset(&self, 0, sizeof(LDKPrintableString)); return res; } + ~PrintableString() { PrintableString_free(self); } + PrintableString& operator=(PrintableString&& o) { PrintableString_free(self); self = o.self; memset(&o, 0, sizeof(PrintableString)); return *this; } + LDKPrintableString* operator &() { return &self; } + LDKPrintableString* operator ->() { return &self; } + const LDKPrintableString* operator &() const { return &self; } + const LDKPrintableString* operator ->() const { return &self; } }; -class RoutingMessageHandler { +class CustomMessageReader { private: - LDKRoutingMessageHandler self; + LDKCustomMessageReader self; public: - RoutingMessageHandler(const RoutingMessageHandler&) = delete; - RoutingMessageHandler(RoutingMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingMessageHandler)); } - RoutingMessageHandler(LDKRoutingMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingMessageHandler)); } - operator LDKRoutingMessageHandler() && { LDKRoutingMessageHandler res = self; memset(&self, 0, sizeof(LDKRoutingMessageHandler)); return res; } - ~RoutingMessageHandler() { RoutingMessageHandler_free(self); } - RoutingMessageHandler& operator=(RoutingMessageHandler&& o) { RoutingMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(RoutingMessageHandler)); return *this; } - LDKRoutingMessageHandler* operator &() { return &self; } - LDKRoutingMessageHandler* operator ->() { return &self; } - const LDKRoutingMessageHandler* operator &() const { return &self; } - const LDKRoutingMessageHandler* operator ->() const { return &self; } - /** - * Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, - * `false` or returning an `Err` otherwise. - */ - inline LDK::CResult_boolLightningErrorZ handle_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); - /** - * Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` - * or returning an `Err` otherwise. - */ - inline LDK::CResult_boolLightningErrorZ handle_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); - /** - * Handle an incoming `channel_update` message, returning true if it should be forwarded on, - * `false` or returning an `Err` otherwise. - */ - inline LDK::CResult_boolLightningErrorZ handle_channel_update(const struct LDKChannelUpdate *NONNULL_PTR msg); - /** - * Gets channel announcements and updates required to dump our routing table to a remote node, - * starting at the `short_channel_id` indicated by `starting_point` and including announcements - * for a single channel. - */ - inline LDK::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement(uint64_t starting_point); - /** - * Gets a node announcement required to dump our routing table to a remote node, starting at - * the node *after* the provided pubkey and including up to one announcement immediately - * higher (as defined by `::cmp`) than `starting_point`. - * If `None` is provided for `starting_point`, we start at the first node. - * - * Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - inline LDK::NodeAnnouncement get_next_node_announcement(struct LDKNodeId starting_point); - /** - * Called when a connection is established with a peer. This can be used to - * perform routing table synchronization using a strategy defined by the - * implementor. - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. - */ - inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); - /** - * Handles the reply of a query we initiated to learn about channels - * for a given range of blocks. We can expect to receive one or more - * replies to a single query. - */ - inline LDK::CResult_NoneLightningErrorZ handle_reply_channel_range(struct LDKPublicKey their_node_id, struct LDKReplyChannelRange msg); - /** - * Handles the reply of a query we initiated asking for routing gossip - * messages for a list of channels. We should receive this message when - * a node has completed its best effort to send us the pertaining routing - * gossip messages. - */ - inline LDK::CResult_NoneLightningErrorZ handle_reply_short_channel_ids_end(struct LDKPublicKey their_node_id, struct LDKReplyShortChannelIdsEnd msg); - /** - * Handles when a peer asks us to send a list of `short_channel_id`s - * for the requested range of blocks. - */ - inline LDK::CResult_NoneLightningErrorZ handle_query_channel_range(struct LDKPublicKey their_node_id, struct LDKQueryChannelRange msg); - /** - * Handles when a peer asks us to send routing gossip messages for a - * list of `short_channel_id`s. - */ - inline LDK::CResult_NoneLightningErrorZ handle_query_short_channel_ids(struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg); - /** - * Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages - * pending some async action. While there is no guarantee of the rate of future messages, the - * caller should seek to reduce the rate of new gossip messages handled, especially - * [`ChannelAnnouncement`]s. - */ - inline bool processing_queue_high(); - /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. - */ - inline LDK::NodeFeatures provided_node_features(); + CustomMessageReader(const CustomMessageReader&) = delete; + CustomMessageReader(CustomMessageReader&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageReader)); } + CustomMessageReader(LDKCustomMessageReader&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageReader)); } + operator LDKCustomMessageReader() && { LDKCustomMessageReader res = self; memset(&self, 0, sizeof(LDKCustomMessageReader)); return res; } + ~CustomMessageReader() { CustomMessageReader_free(self); } + CustomMessageReader& operator=(CustomMessageReader&& o) { CustomMessageReader_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageReader)); return *this; } + LDKCustomMessageReader* operator &() { return &self; } + LDKCustomMessageReader* operator ->() { return &self; } + const LDKCustomMessageReader* operator &() const { return &self; } + const LDKCustomMessageReader* operator ->() const { return &self; } /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. - * - * Note that this method is called before [`Self::peer_connected`]. + * Decodes a custom message to `CustomMessageType`. If the given message type is known to the + * implementation and the message could be decoded, must return `Ok(Some(message))`. If the + * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error + * occur, must return `Err(DecodeError::X)` where `X` details the encountered error. */ - inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); + inline LDK::CResult_COption_TypeZDecodeErrorZ read(uint16_t message_type, struct LDKu8slice buffer); }; -class OnionMessageHandler { +class Type { private: - LDKOnionMessageHandler self; + LDKType self; public: - OnionMessageHandler(const OnionMessageHandler&) = delete; - OnionMessageHandler(OnionMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageHandler)); } - OnionMessageHandler(LDKOnionMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageHandler)); } - operator LDKOnionMessageHandler() && { LDKOnionMessageHandler res = self; memset(&self, 0, sizeof(LDKOnionMessageHandler)); return res; } - ~OnionMessageHandler() { OnionMessageHandler_free(self); } - OnionMessageHandler& operator=(OnionMessageHandler&& o) { OnionMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageHandler)); return *this; } - LDKOnionMessageHandler* operator &() { return &self; } - LDKOnionMessageHandler* operator ->() { return &self; } - const LDKOnionMessageHandler* operator &() const { return &self; } - const LDKOnionMessageHandler* operator ->() const { return &self; } - /** - * Handle an incoming `onion_message` message from the given peer. - */ - inline void handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg); + Type(const Type&) = delete; + Type(Type&& o) : self(o.self) { memset(&o, 0, sizeof(Type)); } + Type(LDKType&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKType)); } + operator LDKType() && { LDKType res = self; memset(&self, 0, sizeof(LDKType)); return res; } + ~Type() { Type_free(self); } + Type& operator=(Type&& o) { Type_free(self); self = o.self; memset(&o, 0, sizeof(Type)); return *this; } + LDKType* operator &() { return &self; } + LDKType* operator ->() { return &self; } + const LDKType* operator &() const { return &self; } + const LDKType* operator ->() const { return &self; } /** - * Called when a connection is established with a peer. Can be used to track which peers - * advertise onion message support and are online. - * - * May return an `Err(())` if the features the peer supports are not sufficient to communicate - * with us. Implementors should be somewhat conservative about doing so, however, as other - * message handlers may still wish to communicate with this peer. + * Returns the type identifying the message payload. */ - inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init, bool inbound); + inline uint16_t type_id(); /** - * Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to - * drop and refuse to forward onion messages to this peer. + * Return a human-readable "debug" string describing this object */ - inline void peer_disconnected(struct LDKPublicKey their_node_id); + inline LDK::Str debug_str(); +}; +class PaymentError { +private: + LDKPaymentError self; +public: + PaymentError(const PaymentError&) = delete; + PaymentError(PaymentError&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentError)); } + PaymentError(LDKPaymentError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentError)); } + operator LDKPaymentError() && { LDKPaymentError res = self; memset(&self, 0, sizeof(LDKPaymentError)); return res; } + ~PaymentError() { PaymentError_free(self); } + PaymentError& operator=(PaymentError&& o) { PaymentError_free(self); self = o.self; memset(&o, 0, sizeof(PaymentError)); return *this; } + LDKPaymentError* operator &() { return &self; } + LDKPaymentError* operator ->() { return &self; } + const LDKPaymentError* operator &() const { return &self; } + const LDKPaymentError* operator ->() const { return &self; } +}; +class UtxoLookupError { +private: + LDKUtxoLookupError self; +public: + UtxoLookupError(const UtxoLookupError&) = delete; + UtxoLookupError(UtxoLookupError&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoLookupError)); } + UtxoLookupError(LDKUtxoLookupError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoLookupError)); } + operator LDKUtxoLookupError() && { LDKUtxoLookupError res = self; memset(&self, 0, sizeof(LDKUtxoLookupError)); return res; } + UtxoLookupError& operator=(UtxoLookupError&& o) { self = o.self; memset(&o, 0, sizeof(UtxoLookupError)); return *this; } + LDKUtxoLookupError* operator &() { return &self; } + LDKUtxoLookupError* operator ->() { return &self; } + const LDKUtxoLookupError* operator &() const { return &self; } + const LDKUtxoLookupError* operator ->() const { return &self; } +}; +class UtxoResult { +private: + LDKUtxoResult self; +public: + UtxoResult(const UtxoResult&) = delete; + UtxoResult(UtxoResult&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoResult)); } + UtxoResult(LDKUtxoResult&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoResult)); } + operator LDKUtxoResult() && { LDKUtxoResult res = self; memset(&self, 0, sizeof(LDKUtxoResult)); return res; } + ~UtxoResult() { UtxoResult_free(self); } + UtxoResult& operator=(UtxoResult&& o) { UtxoResult_free(self); self = o.self; memset(&o, 0, sizeof(UtxoResult)); return *this; } + LDKUtxoResult* operator &() { return &self; } + LDKUtxoResult* operator ->() { return &self; } + const LDKUtxoResult* operator &() const { return &self; } + const LDKUtxoResult* operator ->() const { return &self; } +}; +class UtxoLookup { +private: + LDKUtxoLookup self; +public: + UtxoLookup(const UtxoLookup&) = delete; + UtxoLookup(UtxoLookup&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoLookup)); } + UtxoLookup(LDKUtxoLookup&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoLookup)); } + operator LDKUtxoLookup() && { LDKUtxoLookup res = self; memset(&self, 0, sizeof(LDKUtxoLookup)); return res; } + ~UtxoLookup() { UtxoLookup_free(self); } + UtxoLookup& operator=(UtxoLookup&& o) { UtxoLookup_free(self); self = o.self; memset(&o, 0, sizeof(UtxoLookup)); return *this; } + LDKUtxoLookup* operator &() { return &self; } + LDKUtxoLookup* operator ->() { return &self; } + const LDKUtxoLookup* operator &() const { return &self; } + const LDKUtxoLookup* operator ->() const { return &self; } /** - * Gets the node feature flags which this handler itself supports. All available handlers are - * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] - * which are broadcasted in our [`NodeAnnouncement`] message. + * Returns the transaction output of a funding transaction encoded by [`short_channel_id`]. + * Returns an error if `genesis_hash` is for a different chain or if such a transaction output + * is unknown. + * + * [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id */ - inline LDK::NodeFeatures provided_node_features(); + inline LDK::UtxoResult get_utxo(const uint8_t (*genesis_hash)[32], uint64_t short_channel_id); +}; +class UtxoFuture { +private: + LDKUtxoFuture self; +public: + UtxoFuture(const UtxoFuture&) = delete; + UtxoFuture(UtxoFuture&& o) : self(o.self) { memset(&o, 0, sizeof(UtxoFuture)); } + UtxoFuture(LDKUtxoFuture&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUtxoFuture)); } + operator LDKUtxoFuture() && { LDKUtxoFuture res = self; memset(&self, 0, sizeof(LDKUtxoFuture)); return res; } + ~UtxoFuture() { UtxoFuture_free(self); } + UtxoFuture& operator=(UtxoFuture&& o) { UtxoFuture_free(self); self = o.self; memset(&o, 0, sizeof(UtxoFuture)); return *this; } + LDKUtxoFuture* operator &() { return &self; } + LDKUtxoFuture* operator ->() { return &self; } + const LDKUtxoFuture* operator &() const { return &self; } + const LDKUtxoFuture* operator ->() const { return &self; } +}; +class OnionMessenger { +private: + LDKOnionMessenger self; +public: + OnionMessenger(const OnionMessenger&) = delete; + OnionMessenger(OnionMessenger&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessenger)); } + OnionMessenger(LDKOnionMessenger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessenger)); } + operator LDKOnionMessenger() && { LDKOnionMessenger res = self; memset(&self, 0, sizeof(LDKOnionMessenger)); return res; } + ~OnionMessenger() { OnionMessenger_free(self); } + OnionMessenger& operator=(OnionMessenger&& o) { OnionMessenger_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessenger)); return *this; } + LDKOnionMessenger* operator &() { return &self; } + LDKOnionMessenger* operator ->() { return &self; } + const LDKOnionMessenger* operator &() const { return &self; } + const LDKOnionMessenger* operator ->() const { return &self; } +}; +class MessageRouter { +private: + LDKMessageRouter self; +public: + MessageRouter(const MessageRouter&) = delete; + MessageRouter(MessageRouter&& o) : self(o.self) { memset(&o, 0, sizeof(MessageRouter)); } + MessageRouter(LDKMessageRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageRouter)); } + operator LDKMessageRouter() && { LDKMessageRouter res = self; memset(&self, 0, sizeof(LDKMessageRouter)); return res; } + ~MessageRouter() { MessageRouter_free(self); } + MessageRouter& operator=(MessageRouter&& o) { MessageRouter_free(self); self = o.self; memset(&o, 0, sizeof(MessageRouter)); return *this; } + LDKMessageRouter* operator &() { return &self; } + LDKMessageRouter* operator ->() { return &self; } + const LDKMessageRouter* operator &() const { return &self; } + const LDKMessageRouter* operator ->() const { return &self; } /** - * Gets the init feature flags which should be sent to the given peer. All available handlers - * are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] - * which are sent in our [`Init`] message. + * Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. * - * Note that this method is called before [`Self::peer_connected`]. + * [`OnionMessage`]: msgs::OnionMessage */ - inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); + inline LDK::CResult_OnionMessagePathNoneZ find_path(struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); +}; +class DefaultMessageRouter { +private: + LDKDefaultMessageRouter self; +public: + DefaultMessageRouter(const DefaultMessageRouter&) = delete; + DefaultMessageRouter(DefaultMessageRouter&& o) : self(o.self) { memset(&o, 0, sizeof(DefaultMessageRouter)); } + DefaultMessageRouter(LDKDefaultMessageRouter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDefaultMessageRouter)); } + operator LDKDefaultMessageRouter() && { LDKDefaultMessageRouter res = self; memset(&self, 0, sizeof(LDKDefaultMessageRouter)); return res; } + ~DefaultMessageRouter() { DefaultMessageRouter_free(self); } + DefaultMessageRouter& operator=(DefaultMessageRouter&& o) { DefaultMessageRouter_free(self); self = o.self; memset(&o, 0, sizeof(DefaultMessageRouter)); return *this; } + LDKDefaultMessageRouter* operator &() { return &self; } + LDKDefaultMessageRouter* operator ->() { return &self; } + const LDKDefaultMessageRouter* operator &() const { return &self; } + const LDKDefaultMessageRouter* operator ->() const { return &self; } +}; +class OnionMessagePath { +private: + LDKOnionMessagePath self; +public: + OnionMessagePath(const OnionMessagePath&) = delete; + OnionMessagePath(OnionMessagePath&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessagePath)); } + OnionMessagePath(LDKOnionMessagePath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessagePath)); } + operator LDKOnionMessagePath() && { LDKOnionMessagePath res = self; memset(&self, 0, sizeof(LDKOnionMessagePath)); return res; } + ~OnionMessagePath() { OnionMessagePath_free(self); } + OnionMessagePath& operator=(OnionMessagePath&& o) { OnionMessagePath_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessagePath)); return *this; } + LDKOnionMessagePath* operator &() { return &self; } + LDKOnionMessagePath* operator ->() { return &self; } + const LDKOnionMessagePath* operator &() const { return &self; } + const LDKOnionMessagePath* operator ->() const { return &self; } }; -class UnsignedInvoiceRequest { +class Destination { private: - LDKUnsignedInvoiceRequest self; + LDKDestination self; public: - UnsignedInvoiceRequest(const UnsignedInvoiceRequest&) = delete; - UnsignedInvoiceRequest(UnsignedInvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedInvoiceRequest)); } - UnsignedInvoiceRequest(LDKUnsignedInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedInvoiceRequest)); } - operator LDKUnsignedInvoiceRequest() && { LDKUnsignedInvoiceRequest res = self; memset(&self, 0, sizeof(LDKUnsignedInvoiceRequest)); return res; } - ~UnsignedInvoiceRequest() { UnsignedInvoiceRequest_free(self); } - UnsignedInvoiceRequest& operator=(UnsignedInvoiceRequest&& o) { UnsignedInvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedInvoiceRequest)); return *this; } - LDKUnsignedInvoiceRequest* operator &() { return &self; } - LDKUnsignedInvoiceRequest* operator ->() { return &self; } - const LDKUnsignedInvoiceRequest* operator &() const { return &self; } - const LDKUnsignedInvoiceRequest* operator ->() const { return &self; } + Destination(const Destination&) = delete; + Destination(Destination&& o) : self(o.self) { memset(&o, 0, sizeof(Destination)); } + Destination(LDKDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDestination)); } + operator LDKDestination() && { LDKDestination res = self; memset(&self, 0, sizeof(LDKDestination)); return res; } + ~Destination() { Destination_free(self); } + Destination& operator=(Destination&& o) { Destination_free(self); self = o.self; memset(&o, 0, sizeof(Destination)); return *this; } + LDKDestination* operator &() { return &self; } + LDKDestination* operator ->() { return &self; } + const LDKDestination* operator &() const { return &self; } + const LDKDestination* operator ->() const { return &self; } }; -class InvoiceRequest { +class SendError { private: - LDKInvoiceRequest self; + LDKSendError self; public: - InvoiceRequest(const InvoiceRequest&) = delete; - InvoiceRequest(InvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequest)); } - InvoiceRequest(LDKInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequest)); } - operator LDKInvoiceRequest() && { LDKInvoiceRequest res = self; memset(&self, 0, sizeof(LDKInvoiceRequest)); return res; } - ~InvoiceRequest() { InvoiceRequest_free(self); } - InvoiceRequest& operator=(InvoiceRequest&& o) { InvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequest)); return *this; } - LDKInvoiceRequest* operator &() { return &self; } - LDKInvoiceRequest* operator ->() { return &self; } - const LDKInvoiceRequest* operator &() const { return &self; } - const LDKInvoiceRequest* operator ->() const { return &self; } + SendError(const SendError&) = delete; + SendError(SendError&& o) : self(o.self) { memset(&o, 0, sizeof(SendError)); } + SendError(LDKSendError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSendError)); } + operator LDKSendError() && { LDKSendError res = self; memset(&self, 0, sizeof(LDKSendError)); return res; } + ~SendError() { SendError_free(self); } + SendError& operator=(SendError&& o) { SendError_free(self); self = o.self; memset(&o, 0, sizeof(SendError)); return *this; } + LDKSendError* operator &() { return &self; } + LDKSendError* operator ->() { return &self; } + const LDKSendError* operator &() const { return &self; } + const LDKSendError* operator ->() const { return &self; } }; -class Level { +class CustomOnionMessageHandler { private: - LDKLevel self; + LDKCustomOnionMessageHandler self; public: - Level(const Level&) = delete; - Level(Level&& o) : self(o.self) { memset(&o, 0, sizeof(Level)); } - Level(LDKLevel&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLevel)); } - operator LDKLevel() && { LDKLevel res = self; memset(&self, 0, sizeof(LDKLevel)); return res; } - Level& operator=(Level&& o) { self = o.self; memset(&o, 0, sizeof(Level)); return *this; } - LDKLevel* operator &() { return &self; } - LDKLevel* operator ->() { return &self; } - const LDKLevel* operator &() const { return &self; } - const LDKLevel* operator ->() const { return &self; } + CustomOnionMessageHandler(const CustomOnionMessageHandler&) = delete; + CustomOnionMessageHandler(CustomOnionMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageHandler)); } + CustomOnionMessageHandler(LDKCustomOnionMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageHandler)); } + operator LDKCustomOnionMessageHandler() && { LDKCustomOnionMessageHandler res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageHandler)); return res; } + ~CustomOnionMessageHandler() { CustomOnionMessageHandler_free(self); } + CustomOnionMessageHandler& operator=(CustomOnionMessageHandler&& o) { CustomOnionMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageHandler)); return *this; } + LDKCustomOnionMessageHandler* operator &() { return &self; } + LDKCustomOnionMessageHandler* operator ->() { return &self; } + const LDKCustomOnionMessageHandler* operator &() const { return &self; } + const LDKCustomOnionMessageHandler* operator ->() const { return &self; } + /** + * Called with the custom message that was received, returning a response to send, if any. + */ + inline LDK::COption_CustomOnionMessageContentsZ handle_custom_message(struct LDKCustomOnionMessageContents msg); + /** + * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the + * message type is unknown. + */ + inline LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message(uint64_t message_type, struct LDKu8slice buffer); }; -class Record { +class BlindedPath { private: - LDKRecord self; -public: - Record(const Record&) = delete; - Record(Record&& o) : self(o.self) { memset(&o, 0, sizeof(Record)); } - Record(LDKRecord&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecord)); } - operator LDKRecord() && { LDKRecord res = self; memset(&self, 0, sizeof(LDKRecord)); return res; } - ~Record() { Record_free(self); } - Record& operator=(Record&& o) { Record_free(self); self = o.self; memset(&o, 0, sizeof(Record)); return *this; } - LDKRecord* operator &() { return &self; } - LDKRecord* operator ->() { return &self; } - const LDKRecord* operator &() const { return &self; } - const LDKRecord* operator ->() const { return &self; } + LDKBlindedPath self; +public: + BlindedPath(const BlindedPath&) = delete; + BlindedPath(BlindedPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPath)); } + BlindedPath(LDKBlindedPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPath)); } + operator LDKBlindedPath() && { LDKBlindedPath res = self; memset(&self, 0, sizeof(LDKBlindedPath)); return res; } + ~BlindedPath() { BlindedPath_free(self); } + BlindedPath& operator=(BlindedPath&& o) { BlindedPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPath)); return *this; } + LDKBlindedPath* operator &() { return &self; } + LDKBlindedPath* operator ->() { return &self; } + const LDKBlindedPath* operator &() const { return &self; } + const LDKBlindedPath* operator ->() const { return &self; } }; -class Logger { +class BlindedHop { private: - LDKLogger self; + LDKBlindedHop self; public: - Logger(const Logger&) = delete; - Logger(Logger&& o) : self(o.self) { memset(&o, 0, sizeof(Logger)); } - Logger(LDKLogger&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLogger)); } - operator LDKLogger() && { LDKLogger res = self; memset(&self, 0, sizeof(LDKLogger)); return res; } - ~Logger() { Logger_free(self); } - Logger& operator=(Logger&& o) { Logger_free(self); self = o.self; memset(&o, 0, sizeof(Logger)); return *this; } - LDKLogger* operator &() { return &self; } - LDKLogger* operator ->() { return &self; } - const LDKLogger* operator &() const { return &self; } - const LDKLogger* operator ->() const { return &self; } - /** - * Logs the `Record` - */ - inline void log(const struct LDKRecord *NONNULL_PTR record); + BlindedHop(const BlindedHop&) = delete; + BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } + BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } + operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } + ~BlindedHop() { BlindedHop_free(self); } + BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } + LDKBlindedHop* operator &() { return &self; } + LDKBlindedHop* operator ->() { return &self; } + const LDKBlindedHop* operator &() const { return &self; } + const LDKBlindedHop* operator ->() const { return &self; } }; -class FutureCallback { +class GraphSyncError { private: - LDKFutureCallback self; + LDKGraphSyncError self; public: - FutureCallback(const FutureCallback&) = delete; - FutureCallback(FutureCallback&& o) : self(o.self) { memset(&o, 0, sizeof(FutureCallback)); } - FutureCallback(LDKFutureCallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFutureCallback)); } - operator LDKFutureCallback() && { LDKFutureCallback res = self; memset(&self, 0, sizeof(LDKFutureCallback)); return res; } - ~FutureCallback() { FutureCallback_free(self); } - FutureCallback& operator=(FutureCallback&& o) { FutureCallback_free(self); self = o.self; memset(&o, 0, sizeof(FutureCallback)); return *this; } - LDKFutureCallback* operator &() { return &self; } - LDKFutureCallback* operator ->() { return &self; } - const LDKFutureCallback* operator &() const { return &self; } - const LDKFutureCallback* operator ->() const { return &self; } - /** - * The method which is called. - */ - inline void call(); + GraphSyncError(const GraphSyncError&) = delete; + GraphSyncError(GraphSyncError&& o) : self(o.self) { memset(&o, 0, sizeof(GraphSyncError)); } + GraphSyncError(LDKGraphSyncError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGraphSyncError)); } + operator LDKGraphSyncError() && { LDKGraphSyncError res = self; memset(&self, 0, sizeof(LDKGraphSyncError)); return res; } + ~GraphSyncError() { GraphSyncError_free(self); } + GraphSyncError& operator=(GraphSyncError&& o) { GraphSyncError_free(self); self = o.self; memset(&o, 0, sizeof(GraphSyncError)); return *this; } + LDKGraphSyncError* operator &() { return &self; } + LDKGraphSyncError* operator ->() { return &self; } + const LDKGraphSyncError* operator &() const { return &self; } + const LDKGraphSyncError* operator ->() const { return &self; } }; -class Future { +class InvoiceError { private: - LDKFuture self; + LDKInvoiceError self; public: - Future(const Future&) = delete; - Future(Future&& o) : self(o.self) { memset(&o, 0, sizeof(Future)); } - Future(LDKFuture&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFuture)); } - operator LDKFuture() && { LDKFuture res = self; memset(&self, 0, sizeof(LDKFuture)); return res; } - ~Future() { Future_free(self); } - Future& operator=(Future&& o) { Future_free(self); self = o.self; memset(&o, 0, sizeof(Future)); return *this; } - LDKFuture* operator &() { return &self; } - LDKFuture* operator ->() { return &self; } - const LDKFuture* operator &() const { return &self; } - const LDKFuture* operator ->() const { return &self; } + InvoiceError(const InvoiceError&) = delete; + InvoiceError(InvoiceError&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceError)); } + InvoiceError(LDKInvoiceError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceError)); } + operator LDKInvoiceError() && { LDKInvoiceError res = self; memset(&self, 0, sizeof(LDKInvoiceError)); return res; } + ~InvoiceError() { InvoiceError_free(self); } + InvoiceError& operator=(InvoiceError&& o) { InvoiceError_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceError)); return *this; } + LDKInvoiceError* operator &() { return &self; } + LDKInvoiceError* operator ->() { return &self; } + const LDKInvoiceError* operator &() const { return &self; } + const LDKInvoiceError* operator ->() const { return &self; } }; -class Sleeper { +class ErroneousField { private: - LDKSleeper self; + LDKErroneousField self; public: - Sleeper(const Sleeper&) = delete; - Sleeper(Sleeper&& o) : self(o.self) { memset(&o, 0, sizeof(Sleeper)); } - Sleeper(LDKSleeper&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSleeper)); } - operator LDKSleeper() && { LDKSleeper res = self; memset(&self, 0, sizeof(LDKSleeper)); return res; } - ~Sleeper() { Sleeper_free(self); } - Sleeper& operator=(Sleeper&& o) { Sleeper_free(self); self = o.self; memset(&o, 0, sizeof(Sleeper)); return *this; } - LDKSleeper* operator &() { return &self; } - LDKSleeper* operator ->() { return &self; } - const LDKSleeper* operator &() const { return &self; } - const LDKSleeper* operator ->() const { return &self; } + ErroneousField(const ErroneousField&) = delete; + ErroneousField(ErroneousField&& o) : self(o.self) { memset(&o, 0, sizeof(ErroneousField)); } + ErroneousField(LDKErroneousField&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErroneousField)); } + operator LDKErroneousField() && { LDKErroneousField res = self; memset(&self, 0, sizeof(LDKErroneousField)); return res; } + ~ErroneousField() { ErroneousField_free(self); } + ErroneousField& operator=(ErroneousField&& o) { ErroneousField_free(self); self = o.self; memset(&o, 0, sizeof(ErroneousField)); return *this; } + LDKErroneousField* operator &() { return &self; } + LDKErroneousField* operator ->() { return &self; } + const LDKErroneousField* operator &() const { return &self; } + const LDKErroneousField* operator ->() const { return &self; } }; class MonitorUpdateId { private: @@ -4813,36 +5628,6 @@ public: const LDKChainMonitor* operator &() const { return &self; } const LDKChainMonitor* operator ->() const { return &self; } }; -class GraphSyncError { -private: - LDKGraphSyncError self; -public: - GraphSyncError(const GraphSyncError&) = delete; - GraphSyncError(GraphSyncError&& o) : self(o.self) { memset(&o, 0, sizeof(GraphSyncError)); } - GraphSyncError(LDKGraphSyncError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGraphSyncError)); } - operator LDKGraphSyncError() && { LDKGraphSyncError res = self; memset(&self, 0, sizeof(LDKGraphSyncError)); return res; } - ~GraphSyncError() { GraphSyncError_free(self); } - GraphSyncError& operator=(GraphSyncError&& o) { GraphSyncError_free(self); self = o.self; memset(&o, 0, sizeof(GraphSyncError)); return *this; } - LDKGraphSyncError* operator &() { return &self; } - LDKGraphSyncError* operator ->() { return &self; } - const LDKGraphSyncError* operator &() const { return &self; } - const LDKGraphSyncError* operator ->() const { return &self; } -}; -class RapidGossipSync { -private: - LDKRapidGossipSync self; -public: - RapidGossipSync(const RapidGossipSync&) = delete; - RapidGossipSync(RapidGossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(RapidGossipSync)); } - RapidGossipSync(LDKRapidGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRapidGossipSync)); } - operator LDKRapidGossipSync() && { LDKRapidGossipSync res = self; memset(&self, 0, sizeof(LDKRapidGossipSync)); return res; } - ~RapidGossipSync() { RapidGossipSync_free(self); } - RapidGossipSync& operator=(RapidGossipSync&& o) { RapidGossipSync_free(self); self = o.self; memset(&o, 0, sizeof(RapidGossipSync)); return *this; } - LDKRapidGossipSync* operator &() { return &self; } - LDKRapidGossipSync* operator ->() { return &self; } - const LDKRapidGossipSync* operator &() const { return &self; } - const LDKRapidGossipSync* operator ->() const { return &self; } -}; class CResult_LockedChannelMonitorNoneZ { private: LDKCResult_LockedChannelMonitorNoneZ self; @@ -4858,6 +5643,21 @@ public: const LDKCResult_LockedChannelMonitorNoneZ* operator &() const { return &self; } const LDKCResult_LockedChannelMonitorNoneZ* operator ->() const { return &self; } }; +class CResult_TransactionU16LenLimitedNoneZ { +private: + LDKCResult_TransactionU16LenLimitedNoneZ self; +public: + CResult_TransactionU16LenLimitedNoneZ(const CResult_TransactionU16LenLimitedNoneZ&) = delete; + CResult_TransactionU16LenLimitedNoneZ(CResult_TransactionU16LenLimitedNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedNoneZ)); } + CResult_TransactionU16LenLimitedNoneZ(LDKCResult_TransactionU16LenLimitedNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionU16LenLimitedNoneZ)); } + operator LDKCResult_TransactionU16LenLimitedNoneZ() && { LDKCResult_TransactionU16LenLimitedNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionU16LenLimitedNoneZ)); return res; } + ~CResult_TransactionU16LenLimitedNoneZ() { CResult_TransactionU16LenLimitedNoneZ_free(self); } + CResult_TransactionU16LenLimitedNoneZ& operator=(CResult_TransactionU16LenLimitedNoneZ&& o) { CResult_TransactionU16LenLimitedNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedNoneZ)); return *this; } + LDKCResult_TransactionU16LenLimitedNoneZ* operator &() { return &self; } + LDKCResult_TransactionU16LenLimitedNoneZ* operator ->() { return &self; } + const LDKCResult_TransactionU16LenLimitedNoneZ* operator &() const { return &self; } + const LDKCResult_TransactionU16LenLimitedNoneZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { private: LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ self; @@ -4888,20 +5688,20 @@ public: const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +class CResult_FundingCreatedDecodeErrorZ { private: - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ self; + LDKCResult_FundingCreatedDecodeErrorZ self; public: - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(const CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&) = delete; - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } - operator LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() && { LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return res; } - ~CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ& operator=(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return *this; } - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() { return &self; } - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() { return &self; } - const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() const { return &self; } - const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() const { return &self; } + CResult_FundingCreatedDecodeErrorZ(const CResult_FundingCreatedDecodeErrorZ&) = delete; + CResult_FundingCreatedDecodeErrorZ(CResult_FundingCreatedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); } + CResult_FundingCreatedDecodeErrorZ(LDKCResult_FundingCreatedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); } + operator LDKCResult_FundingCreatedDecodeErrorZ() && { LDKCResult_FundingCreatedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); return res; } + ~CResult_FundingCreatedDecodeErrorZ() { CResult_FundingCreatedDecodeErrorZ_free(self); } + CResult_FundingCreatedDecodeErrorZ& operator=(CResult_FundingCreatedDecodeErrorZ&& o) { CResult_FundingCreatedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); return *this; } + LDKCResult_FundingCreatedDecodeErrorZ* operator &() { return &self; } + LDKCResult_FundingCreatedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FundingCreatedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FundingCreatedDecodeErrorZ* operator ->() const { return &self; } }; class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { private: @@ -4933,20 +5733,35 @@ public: const LDKCVec_C2Tuple_u32TxOutZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32TxOutZZ* operator ->() const { return &self; } }; -class CResult_FundingCreatedDecodeErrorZ { +class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { private: - LDKCResult_FundingCreatedDecodeErrorZ self; + LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ self; public: - CResult_FundingCreatedDecodeErrorZ(const CResult_FundingCreatedDecodeErrorZ&) = delete; - CResult_FundingCreatedDecodeErrorZ(CResult_FundingCreatedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); } - CResult_FundingCreatedDecodeErrorZ(LDKCResult_FundingCreatedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); } - operator LDKCResult_FundingCreatedDecodeErrorZ() && { LDKCResult_FundingCreatedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); return res; } - ~CResult_FundingCreatedDecodeErrorZ() { CResult_FundingCreatedDecodeErrorZ_free(self); } - CResult_FundingCreatedDecodeErrorZ& operator=(CResult_FundingCreatedDecodeErrorZ&& o) { CResult_FundingCreatedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); return *this; } - LDKCResult_FundingCreatedDecodeErrorZ* operator &() { return &self; } - LDKCResult_FundingCreatedDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_FundingCreatedDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_FundingCreatedDecodeErrorZ* operator ->() const { return &self; } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(const CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&) = delete; + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } + operator LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() && { LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return res; } + ~CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ& operator=(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return *this; } + LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() { return &self; } + LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() { return &self; } + const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() const { return &self; } + const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() const { return &self; } +}; +class COption_PaymentSecretZ { +private: + LDKCOption_PaymentSecretZ self; +public: + COption_PaymentSecretZ(const COption_PaymentSecretZ&) = delete; + COption_PaymentSecretZ(COption_PaymentSecretZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentSecretZ)); } + COption_PaymentSecretZ(LDKCOption_PaymentSecretZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentSecretZ)); } + operator LDKCOption_PaymentSecretZ() && { LDKCOption_PaymentSecretZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentSecretZ)); return res; } + ~COption_PaymentSecretZ() { COption_PaymentSecretZ_free(self); } + COption_PaymentSecretZ& operator=(COption_PaymentSecretZ&& o) { COption_PaymentSecretZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentSecretZ)); return *this; } + LDKCOption_PaymentSecretZ* operator &() { return &self; } + LDKCOption_PaymentSecretZ* operator ->() { return &self; } + const LDKCOption_PaymentSecretZ* operator &() const { return &self; } + const LDKCOption_PaymentSecretZ* operator ->() const { return &self; } }; class CResult_ChannelInfoDecodeErrorZ { private: @@ -4963,6 +5778,21 @@ public: const LDKCResult_ChannelInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelInfoDecodeErrorZ* operator ->() const { return &self; } }; +class COption_MaxDustHTLCExposureZ { +private: + LDKCOption_MaxDustHTLCExposureZ self; +public: + COption_MaxDustHTLCExposureZ(const COption_MaxDustHTLCExposureZ&) = delete; + COption_MaxDustHTLCExposureZ(COption_MaxDustHTLCExposureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_MaxDustHTLCExposureZ)); } + COption_MaxDustHTLCExposureZ(LDKCOption_MaxDustHTLCExposureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_MaxDustHTLCExposureZ)); } + operator LDKCOption_MaxDustHTLCExposureZ() && { LDKCOption_MaxDustHTLCExposureZ res = self; memset(&self, 0, sizeof(LDKCOption_MaxDustHTLCExposureZ)); return res; } + ~COption_MaxDustHTLCExposureZ() { COption_MaxDustHTLCExposureZ_free(self); } + COption_MaxDustHTLCExposureZ& operator=(COption_MaxDustHTLCExposureZ&& o) { COption_MaxDustHTLCExposureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_MaxDustHTLCExposureZ)); return *this; } + LDKCOption_MaxDustHTLCExposureZ* operator &() { return &self; } + LDKCOption_MaxDustHTLCExposureZ* operator ->() { return &self; } + const LDKCOption_MaxDustHTLCExposureZ* operator &() const { return &self; } + const LDKCOption_MaxDustHTLCExposureZ* operator ->() const { return &self; } +}; class CResult_NoneSendErrorZ { private: LDKCResult_NoneSendErrorZ self; @@ -4978,6 +5808,21 @@ public: const LDKCResult_NoneSendErrorZ* operator &() const { return &self; } const LDKCResult_NoneSendErrorZ* operator ->() const { return &self; } }; +class COption_OffersMessageZ { +private: + LDKCOption_OffersMessageZ self; +public: + COption_OffersMessageZ(const COption_OffersMessageZ&) = delete; + COption_OffersMessageZ(COption_OffersMessageZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_OffersMessageZ)); } + COption_OffersMessageZ(LDKCOption_OffersMessageZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_OffersMessageZ)); } + operator LDKCOption_OffersMessageZ() && { LDKCOption_OffersMessageZ res = self; memset(&self, 0, sizeof(LDKCOption_OffersMessageZ)); return res; } + ~COption_OffersMessageZ() { COption_OffersMessageZ_free(self); } + COption_OffersMessageZ& operator=(COption_OffersMessageZ&& o) { COption_OffersMessageZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_OffersMessageZ)); return *this; } + LDKCOption_OffersMessageZ* operator &() { return &self; } + LDKCOption_OffersMessageZ* operator ->() { return &self; } + const LDKCOption_OffersMessageZ* operator &() const { return &self; } + const LDKCOption_OffersMessageZ* operator ->() const { return &self; } +}; class CResult_CVec_u8ZPeerHandleErrorZ { private: LDKCResult_CVec_u8ZPeerHandleErrorZ self; @@ -4993,21 +5838,6 @@ public: const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_GossipTimestampFilterDecodeErrorZ { -private: - LDKCResult_GossipTimestampFilterDecodeErrorZ self; -public: - CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete; - CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); } - CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); } - operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; } - ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); } - CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; } - LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; } - LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } -}; class COption_NetworkUpdateZ { private: LDKCOption_NetworkUpdateZ self; @@ -5038,6 +5868,21 @@ public: const LDKCOption_u64Z* operator &() const { return &self; } const LDKCOption_u64Z* operator ->() const { return &self; } }; +class CResult_GossipTimestampFilterDecodeErrorZ { +private: + LDKCResult_GossipTimestampFilterDecodeErrorZ self; +public: + CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete; + CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); } + CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); } + operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; } + ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); } + CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; } + LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; } + LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_PaymentPreimageAPIErrorZ { private: LDKCResult_PaymentPreimageAPIErrorZ self; @@ -5128,35 +5973,20 @@ public: const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; } const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; } }; -class CResult_CommitmentSignedDecodeErrorZ { -private: - LDKCResult_CommitmentSignedDecodeErrorZ self; -public: - CResult_CommitmentSignedDecodeErrorZ(const CResult_CommitmentSignedDecodeErrorZ&) = delete; - CResult_CommitmentSignedDecodeErrorZ(CResult_CommitmentSignedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); } - CResult_CommitmentSignedDecodeErrorZ(LDKCResult_CommitmentSignedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); } - operator LDKCResult_CommitmentSignedDecodeErrorZ() && { LDKCResult_CommitmentSignedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); return res; } - ~CResult_CommitmentSignedDecodeErrorZ() { CResult_CommitmentSignedDecodeErrorZ_free(self); } - CResult_CommitmentSignedDecodeErrorZ& operator=(CResult_CommitmentSignedDecodeErrorZ&& o) { CResult_CommitmentSignedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); return *this; } - LDKCResult_CommitmentSignedDecodeErrorZ* operator &() { return &self; } - LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_CommitmentSignedDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() const { return &self; } -}; -class COption_u32Z { +class CResult_TxAbortDecodeErrorZ { private: - LDKCOption_u32Z self; + LDKCResult_TxAbortDecodeErrorZ self; public: - COption_u32Z(const COption_u32Z&) = delete; - COption_u32Z(COption_u32Z&& o) : self(o.self) { memset(&o, 0, sizeof(COption_u32Z)); } - COption_u32Z(LDKCOption_u32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_u32Z)); } - operator LDKCOption_u32Z() && { LDKCOption_u32Z res = self; memset(&self, 0, sizeof(LDKCOption_u32Z)); return res; } - ~COption_u32Z() { COption_u32Z_free(self); } - COption_u32Z& operator=(COption_u32Z&& o) { COption_u32Z_free(self); self = o.self; memset(&o, 0, sizeof(COption_u32Z)); return *this; } - LDKCOption_u32Z* operator &() { return &self; } - LDKCOption_u32Z* operator ->() { return &self; } - const LDKCOption_u32Z* operator &() const { return &self; } - const LDKCOption_u32Z* operator ->() const { return &self; } + CResult_TxAbortDecodeErrorZ(const CResult_TxAbortDecodeErrorZ&) = delete; + CResult_TxAbortDecodeErrorZ(CResult_TxAbortDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAbortDecodeErrorZ)); } + CResult_TxAbortDecodeErrorZ(LDKCResult_TxAbortDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAbortDecodeErrorZ)); } + operator LDKCResult_TxAbortDecodeErrorZ() && { LDKCResult_TxAbortDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAbortDecodeErrorZ)); return res; } + ~CResult_TxAbortDecodeErrorZ() { CResult_TxAbortDecodeErrorZ_free(self); } + CResult_TxAbortDecodeErrorZ& operator=(CResult_TxAbortDecodeErrorZ&& o) { CResult_TxAbortDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAbortDecodeErrorZ)); return *this; } + LDKCResult_TxAbortDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxAbortDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxAbortDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxAbortDecodeErrorZ* operator ->() const { return &self; } }; class CResult_StaticPaymentOutputDescriptorDecodeErrorZ { private: @@ -5173,35 +6003,50 @@ public: const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() const { return &self; } const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_TxidBlockHashZZ { +class COption_u32Z { +private: + LDKCOption_u32Z self; +public: + COption_u32Z(const COption_u32Z&) = delete; + COption_u32Z(COption_u32Z&& o) : self(o.self) { memset(&o, 0, sizeof(COption_u32Z)); } + COption_u32Z(LDKCOption_u32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_u32Z)); } + operator LDKCOption_u32Z() && { LDKCOption_u32Z res = self; memset(&self, 0, sizeof(LDKCOption_u32Z)); return res; } + ~COption_u32Z() { COption_u32Z_free(self); } + COption_u32Z& operator=(COption_u32Z&& o) { COption_u32Z_free(self); self = o.self; memset(&o, 0, sizeof(COption_u32Z)); return *this; } + LDKCOption_u32Z* operator &() { return &self; } + LDKCOption_u32Z* operator ->() { return &self; } + const LDKCOption_u32Z* operator &() const { return &self; } + const LDKCOption_u32Z* operator ->() const { return &self; } +}; +class CResult_CommitmentSignedDecodeErrorZ { private: - LDKCVec_C2Tuple_TxidBlockHashZZ self; + LDKCResult_CommitmentSignedDecodeErrorZ self; public: - CVec_C2Tuple_TxidBlockHashZZ(const CVec_C2Tuple_TxidBlockHashZZ&) = delete; - CVec_C2Tuple_TxidBlockHashZZ(CVec_C2Tuple_TxidBlockHashZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_TxidBlockHashZZ)); } - CVec_C2Tuple_TxidBlockHashZZ(LDKCVec_C2Tuple_TxidBlockHashZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_TxidBlockHashZZ)); } - operator LDKCVec_C2Tuple_TxidBlockHashZZ() && { LDKCVec_C2Tuple_TxidBlockHashZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_TxidBlockHashZZ)); return res; } - ~CVec_C2Tuple_TxidBlockHashZZ() { CVec_C2Tuple_TxidBlockHashZZ_free(self); } - CVec_C2Tuple_TxidBlockHashZZ& operator=(CVec_C2Tuple_TxidBlockHashZZ&& o) { CVec_C2Tuple_TxidBlockHashZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_TxidBlockHashZZ)); return *this; } - LDKCVec_C2Tuple_TxidBlockHashZZ* operator &() { return &self; } - LDKCVec_C2Tuple_TxidBlockHashZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_TxidBlockHashZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_TxidBlockHashZZ* operator ->() const { return &self; } + CResult_CommitmentSignedDecodeErrorZ(const CResult_CommitmentSignedDecodeErrorZ&) = delete; + CResult_CommitmentSignedDecodeErrorZ(CResult_CommitmentSignedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); } + CResult_CommitmentSignedDecodeErrorZ(LDKCResult_CommitmentSignedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); } + operator LDKCResult_CommitmentSignedDecodeErrorZ() && { LDKCResult_CommitmentSignedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedDecodeErrorZ)); return res; } + ~CResult_CommitmentSignedDecodeErrorZ() { CResult_CommitmentSignedDecodeErrorZ_free(self); } + CResult_CommitmentSignedDecodeErrorZ& operator=(CResult_CommitmentSignedDecodeErrorZ&& o) { CResult_CommitmentSignedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedDecodeErrorZ)); return *this; } + LDKCResult_CommitmentSignedDecodeErrorZ* operator &() { return &self; } + LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CommitmentSignedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CommitmentSignedDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CommitmentTransactionDecodeErrorZ { +class CResult_ClosingSignedFeeRangeDecodeErrorZ { private: - LDKCResult_CommitmentTransactionDecodeErrorZ self; + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ self; public: - CResult_CommitmentTransactionDecodeErrorZ(const CResult_CommitmentTransactionDecodeErrorZ&) = delete; - CResult_CommitmentTransactionDecodeErrorZ(CResult_CommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentTransactionDecodeErrorZ)); } - CResult_CommitmentTransactionDecodeErrorZ(LDKCResult_CommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ)); } - operator LDKCResult_CommitmentTransactionDecodeErrorZ() && { LDKCResult_CommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ)); return res; } - ~CResult_CommitmentTransactionDecodeErrorZ() { CResult_CommitmentTransactionDecodeErrorZ_free(self); } - CResult_CommitmentTransactionDecodeErrorZ& operator=(CResult_CommitmentTransactionDecodeErrorZ&& o) { CResult_CommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentTransactionDecodeErrorZ)); return *this; } - LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() { return &self; } - LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } + CResult_ClosingSignedFeeRangeDecodeErrorZ(const CResult_ClosingSignedFeeRangeDecodeErrorZ&) = delete; + CResult_ClosingSignedFeeRangeDecodeErrorZ(CResult_ClosingSignedFeeRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ClosingSignedFeeRangeDecodeErrorZ)); } + CResult_ClosingSignedFeeRangeDecodeErrorZ(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ)); } + operator LDKCResult_ClosingSignedFeeRangeDecodeErrorZ() && { LDKCResult_ClosingSignedFeeRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ)); return res; } + ~CResult_ClosingSignedFeeRangeDecodeErrorZ() { CResult_ClosingSignedFeeRangeDecodeErrorZ_free(self); } + CResult_ClosingSignedFeeRangeDecodeErrorZ& operator=(CResult_ClosingSignedFeeRangeDecodeErrorZ&& o) { CResult_ClosingSignedFeeRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ClosingSignedFeeRangeDecodeErrorZ)); return *this; } + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() { return &self; } + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() const { return &self; } }; class CResult_TransactionNoneZ { private: @@ -5218,20 +6063,20 @@ public: const LDKCResult_TransactionNoneZ* operator &() const { return &self; } const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } }; -class CResult_ClosingSignedFeeRangeDecodeErrorZ { +class CResult_CommitmentTransactionDecodeErrorZ { private: - LDKCResult_ClosingSignedFeeRangeDecodeErrorZ self; + LDKCResult_CommitmentTransactionDecodeErrorZ self; public: - CResult_ClosingSignedFeeRangeDecodeErrorZ(const CResult_ClosingSignedFeeRangeDecodeErrorZ&) = delete; - CResult_ClosingSignedFeeRangeDecodeErrorZ(CResult_ClosingSignedFeeRangeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ClosingSignedFeeRangeDecodeErrorZ)); } - CResult_ClosingSignedFeeRangeDecodeErrorZ(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ)); } - operator LDKCResult_ClosingSignedFeeRangeDecodeErrorZ() && { LDKCResult_ClosingSignedFeeRangeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ)); return res; } - ~CResult_ClosingSignedFeeRangeDecodeErrorZ() { CResult_ClosingSignedFeeRangeDecodeErrorZ_free(self); } - CResult_ClosingSignedFeeRangeDecodeErrorZ& operator=(CResult_ClosingSignedFeeRangeDecodeErrorZ&& o) { CResult_ClosingSignedFeeRangeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ClosingSignedFeeRangeDecodeErrorZ)); return *this; } - LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() { return &self; } - LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() const { return &self; } + CResult_CommitmentTransactionDecodeErrorZ(const CResult_CommitmentTransactionDecodeErrorZ&) = delete; + CResult_CommitmentTransactionDecodeErrorZ(CResult_CommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentTransactionDecodeErrorZ)); } + CResult_CommitmentTransactionDecodeErrorZ(LDKCResult_CommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ)); } + operator LDKCResult_CommitmentTransactionDecodeErrorZ() && { LDKCResult_CommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ)); return res; } + ~CResult_CommitmentTransactionDecodeErrorZ() { CResult_CommitmentTransactionDecodeErrorZ_free(self); } + CResult_CommitmentTransactionDecodeErrorZ& operator=(CResult_CommitmentTransactionDecodeErrorZ&& o) { CResult_CommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentTransactionDecodeErrorZ)); return *this; } + LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() { return &self; } + LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; class COption_DurationZ { private: @@ -5248,20 +6093,35 @@ public: const LDKCOption_DurationZ* operator &() const { return &self; } const LDKCOption_DurationZ* operator ->() const { return &self; } }; -class CResult_ErrorMessageDecodeErrorZ { +class C2Tuple_TxidCOption_BlockHashZZ { private: - LDKCResult_ErrorMessageDecodeErrorZ self; + LDKC2Tuple_TxidCOption_BlockHashZZ self; public: - CResult_ErrorMessageDecodeErrorZ(const CResult_ErrorMessageDecodeErrorZ&) = delete; - CResult_ErrorMessageDecodeErrorZ(CResult_ErrorMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ErrorMessageDecodeErrorZ)); } - CResult_ErrorMessageDecodeErrorZ(LDKCResult_ErrorMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ErrorMessageDecodeErrorZ)); } - operator LDKCResult_ErrorMessageDecodeErrorZ() && { LDKCResult_ErrorMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ErrorMessageDecodeErrorZ)); return res; } - ~CResult_ErrorMessageDecodeErrorZ() { CResult_ErrorMessageDecodeErrorZ_free(self); } - CResult_ErrorMessageDecodeErrorZ& operator=(CResult_ErrorMessageDecodeErrorZ&& o) { CResult_ErrorMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ErrorMessageDecodeErrorZ)); return *this; } - LDKCResult_ErrorMessageDecodeErrorZ* operator &() { return &self; } - LDKCResult_ErrorMessageDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ErrorMessageDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ErrorMessageDecodeErrorZ* operator ->() const { return &self; } + C2Tuple_TxidCOption_BlockHashZZ(const C2Tuple_TxidCOption_BlockHashZZ&) = delete; + C2Tuple_TxidCOption_BlockHashZZ(C2Tuple_TxidCOption_BlockHashZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidCOption_BlockHashZZ)); } + C2Tuple_TxidCOption_BlockHashZZ(LDKC2Tuple_TxidCOption_BlockHashZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidCOption_BlockHashZZ)); } + operator LDKC2Tuple_TxidCOption_BlockHashZZ() && { LDKC2Tuple_TxidCOption_BlockHashZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidCOption_BlockHashZZ)); return res; } + ~C2Tuple_TxidCOption_BlockHashZZ() { C2Tuple_TxidCOption_BlockHashZZ_free(self); } + C2Tuple_TxidCOption_BlockHashZZ& operator=(C2Tuple_TxidCOption_BlockHashZZ&& o) { C2Tuple_TxidCOption_BlockHashZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_TxidCOption_BlockHashZZ)); return *this; } + LDKC2Tuple_TxidCOption_BlockHashZZ* operator &() { return &self; } + LDKC2Tuple_TxidCOption_BlockHashZZ* operator ->() { return &self; } + const LDKC2Tuple_TxidCOption_BlockHashZZ* operator &() const { return &self; } + const LDKC2Tuple_TxidCOption_BlockHashZZ* operator ->() const { return &self; } +}; +class COption_PaymentHashZ { +private: + LDKCOption_PaymentHashZ self; +public: + COption_PaymentHashZ(const COption_PaymentHashZ&) = delete; + COption_PaymentHashZ(COption_PaymentHashZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentHashZ)); } + COption_PaymentHashZ(LDKCOption_PaymentHashZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentHashZ)); } + operator LDKCOption_PaymentHashZ() && { LDKCOption_PaymentHashZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentHashZ)); return res; } + ~COption_PaymentHashZ() { COption_PaymentHashZ_free(self); } + COption_PaymentHashZ& operator=(COption_PaymentHashZ&& o) { COption_PaymentHashZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentHashZ)); return *this; } + LDKCOption_PaymentHashZ* operator &() { return &self; } + LDKCOption_PaymentHashZ* operator ->() { return &self; } + const LDKCOption_PaymentHashZ* operator &() const { return &self; } + const LDKCOption_PaymentHashZ* operator ->() const { return &self; } }; class CResult_OpenChannelDecodeErrorZ { private: @@ -5278,6 +6138,21 @@ public: const LDKCResult_OpenChannelDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OpenChannelDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ErrorMessageDecodeErrorZ { +private: + LDKCResult_ErrorMessageDecodeErrorZ self; +public: + CResult_ErrorMessageDecodeErrorZ(const CResult_ErrorMessageDecodeErrorZ&) = delete; + CResult_ErrorMessageDecodeErrorZ(CResult_ErrorMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ErrorMessageDecodeErrorZ)); } + CResult_ErrorMessageDecodeErrorZ(LDKCResult_ErrorMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ErrorMessageDecodeErrorZ)); } + operator LDKCResult_ErrorMessageDecodeErrorZ() && { LDKCResult_ErrorMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ErrorMessageDecodeErrorZ)); return res; } + ~CResult_ErrorMessageDecodeErrorZ() { CResult_ErrorMessageDecodeErrorZ_free(self); } + CResult_ErrorMessageDecodeErrorZ& operator=(CResult_ErrorMessageDecodeErrorZ&& o) { CResult_ErrorMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ErrorMessageDecodeErrorZ)); return *this; } + LDKCResult_ErrorMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_ErrorMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ErrorMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ErrorMessageDecodeErrorZ* operator ->() const { return &self; } +}; class COption_APIErrorZ { private: LDKCOption_APIErrorZ self; @@ -5323,20 +6198,35 @@ public: const LDKCVec_TransactionZ* operator &() const { return &self; } const LDKCVec_TransactionZ* operator ->() const { return &self; } }; -class C2Tuple_TxidBlockHashZ { +class CVec_InputZ { private: - LDKC2Tuple_TxidBlockHashZ self; + LDKCVec_InputZ self; public: - C2Tuple_TxidBlockHashZ(const C2Tuple_TxidBlockHashZ&) = delete; - C2Tuple_TxidBlockHashZ(C2Tuple_TxidBlockHashZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidBlockHashZ)); } - C2Tuple_TxidBlockHashZ(LDKC2Tuple_TxidBlockHashZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidBlockHashZ)); } - operator LDKC2Tuple_TxidBlockHashZ() && { LDKC2Tuple_TxidBlockHashZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidBlockHashZ)); return res; } - ~C2Tuple_TxidBlockHashZ() { C2Tuple_TxidBlockHashZ_free(self); } - C2Tuple_TxidBlockHashZ& operator=(C2Tuple_TxidBlockHashZ&& o) { C2Tuple_TxidBlockHashZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_TxidBlockHashZ)); return *this; } - LDKC2Tuple_TxidBlockHashZ* operator &() { return &self; } - LDKC2Tuple_TxidBlockHashZ* operator ->() { return &self; } - const LDKC2Tuple_TxidBlockHashZ* operator &() const { return &self; } - const LDKC2Tuple_TxidBlockHashZ* operator ->() const { return &self; } + CVec_InputZ(const CVec_InputZ&) = delete; + CVec_InputZ(CVec_InputZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_InputZ)); } + CVec_InputZ(LDKCVec_InputZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_InputZ)); } + operator LDKCVec_InputZ() && { LDKCVec_InputZ res = self; memset(&self, 0, sizeof(LDKCVec_InputZ)); return res; } + ~CVec_InputZ() { CVec_InputZ_free(self); } + CVec_InputZ& operator=(CVec_InputZ&& o) { CVec_InputZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_InputZ)); return *this; } + LDKCVec_InputZ* operator &() { return &self; } + LDKCVec_InputZ* operator ->() { return &self; } + const LDKCVec_InputZ* operator &() const { return &self; } + const LDKCVec_InputZ* operator ->() const { return &self; } +}; +class CResult_PartiallySignedTransactionNoneZ { +private: + LDKCResult_PartiallySignedTransactionNoneZ self; +public: + CResult_PartiallySignedTransactionNoneZ(const CResult_PartiallySignedTransactionNoneZ&) = delete; + CResult_PartiallySignedTransactionNoneZ(CResult_PartiallySignedTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PartiallySignedTransactionNoneZ)); } + CResult_PartiallySignedTransactionNoneZ(LDKCResult_PartiallySignedTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PartiallySignedTransactionNoneZ)); } + operator LDKCResult_PartiallySignedTransactionNoneZ() && { LDKCResult_PartiallySignedTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_PartiallySignedTransactionNoneZ)); return res; } + ~CResult_PartiallySignedTransactionNoneZ() { CResult_PartiallySignedTransactionNoneZ_free(self); } + CResult_PartiallySignedTransactionNoneZ& operator=(CResult_PartiallySignedTransactionNoneZ&& o) { CResult_PartiallySignedTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PartiallySignedTransactionNoneZ)); return *this; } + LDKCResult_PartiallySignedTransactionNoneZ* operator &() { return &self; } + LDKCResult_PartiallySignedTransactionNoneZ* operator ->() { return &self; } + const LDKCResult_PartiallySignedTransactionNoneZ* operator &() const { return &self; } + const LDKCResult_PartiallySignedTransactionNoneZ* operator ->() const { return &self; } }; class CResult_ChannelFeaturesDecodeErrorZ { private: @@ -5383,35 +6273,50 @@ public: const LDKCResult_UpdateFeeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFeeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_HTLCOutputInCommitmentDecodeErrorZ { +class CResult_NoneBolt11SemanticErrorZ { private: - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self; + LDKCResult_NoneBolt11SemanticErrorZ self; public: - CResult_HTLCOutputInCommitmentDecodeErrorZ(const CResult_HTLCOutputInCommitmentDecodeErrorZ&) = delete; - CResult_HTLCOutputInCommitmentDecodeErrorZ(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); } - CResult_HTLCOutputInCommitmentDecodeErrorZ(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); } - operator LDKCResult_HTLCOutputInCommitmentDecodeErrorZ() && { LDKCResult_HTLCOutputInCommitmentDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); return res; } - ~CResult_HTLCOutputInCommitmentDecodeErrorZ() { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); } - CResult_HTLCOutputInCommitmentDecodeErrorZ& operator=(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); return *this; } - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() { return &self; } - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() const { return &self; } + CResult_NoneBolt11SemanticErrorZ(const CResult_NoneBolt11SemanticErrorZ&) = delete; + CResult_NoneBolt11SemanticErrorZ(CResult_NoneBolt11SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneBolt11SemanticErrorZ)); } + CResult_NoneBolt11SemanticErrorZ(LDKCResult_NoneBolt11SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneBolt11SemanticErrorZ)); } + operator LDKCResult_NoneBolt11SemanticErrorZ() && { LDKCResult_NoneBolt11SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneBolt11SemanticErrorZ)); return res; } + ~CResult_NoneBolt11SemanticErrorZ() { CResult_NoneBolt11SemanticErrorZ_free(self); } + CResult_NoneBolt11SemanticErrorZ& operator=(CResult_NoneBolt11SemanticErrorZ&& o) { CResult_NoneBolt11SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneBolt11SemanticErrorZ)); return *this; } + LDKCResult_NoneBolt11SemanticErrorZ* operator &() { return &self; } + LDKCResult_NoneBolt11SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_NoneBolt11SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_NoneBolt11SemanticErrorZ* operator ->() const { return &self; } }; -class CResult_boolLightningErrorZ { +class CResult_NoneRetryableSendFailureZ { private: - LDKCResult_boolLightningErrorZ self; + LDKCResult_NoneRetryableSendFailureZ self; public: - CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete; - CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); } - CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); } - operator LDKCResult_boolLightningErrorZ() && { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; } - ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); } - CResult_boolLightningErrorZ& operator=(CResult_boolLightningErrorZ&& o) { CResult_boolLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); return *this; } - LDKCResult_boolLightningErrorZ* operator &() { return &self; } - LDKCResult_boolLightningErrorZ* operator ->() { return &self; } - const LDKCResult_boolLightningErrorZ* operator &() const { return &self; } - const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; } + CResult_NoneRetryableSendFailureZ(const CResult_NoneRetryableSendFailureZ&) = delete; + CResult_NoneRetryableSendFailureZ(CResult_NoneRetryableSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); } + CResult_NoneRetryableSendFailureZ(LDKCResult_NoneRetryableSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); } + operator LDKCResult_NoneRetryableSendFailureZ() && { LDKCResult_NoneRetryableSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); return res; } + ~CResult_NoneRetryableSendFailureZ() { CResult_NoneRetryableSendFailureZ_free(self); } + CResult_NoneRetryableSendFailureZ& operator=(CResult_NoneRetryableSendFailureZ&& o) { CResult_NoneRetryableSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); return *this; } + LDKCResult_NoneRetryableSendFailureZ* operator &() { return &self; } + LDKCResult_NoneRetryableSendFailureZ* operator ->() { return &self; } + const LDKCResult_NoneRetryableSendFailureZ* operator &() const { return &self; } + const LDKCResult_NoneRetryableSendFailureZ* operator ->() const { return &self; } +}; +class COption_BlockHashZ { +private: + LDKCOption_BlockHashZ self; +public: + COption_BlockHashZ(const COption_BlockHashZ&) = delete; + COption_BlockHashZ(COption_BlockHashZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_BlockHashZ)); } + COption_BlockHashZ(LDKCOption_BlockHashZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_BlockHashZ)); } + operator LDKCOption_BlockHashZ() && { LDKCOption_BlockHashZ res = self; memset(&self, 0, sizeof(LDKCOption_BlockHashZ)); return res; } + ~COption_BlockHashZ() { COption_BlockHashZ_free(self); } + COption_BlockHashZ& operator=(COption_BlockHashZ&& o) { COption_BlockHashZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_BlockHashZ)); return *this; } + LDKCOption_BlockHashZ* operator &() { return &self; } + LDKCOption_BlockHashZ* operator ->() { return &self; } + const LDKCOption_BlockHashZ* operator &() const { return &self; } + const LDKCOption_BlockHashZ* operator ->() const { return &self; } }; class CResult_NodeIdDecodeErrorZ { private: @@ -5428,50 +6333,35 @@ public: const LDKCResult_NodeIdDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeIdDecodeErrorZ* operator ->() const { return &self; } }; -class COption_HTLCDestinationZ { -private: - LDKCOption_HTLCDestinationZ self; -public: - COption_HTLCDestinationZ(const COption_HTLCDestinationZ&) = delete; - COption_HTLCDestinationZ(COption_HTLCDestinationZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_HTLCDestinationZ)); } - COption_HTLCDestinationZ(LDKCOption_HTLCDestinationZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_HTLCDestinationZ)); } - operator LDKCOption_HTLCDestinationZ() && { LDKCOption_HTLCDestinationZ res = self; memset(&self, 0, sizeof(LDKCOption_HTLCDestinationZ)); return res; } - ~COption_HTLCDestinationZ() { COption_HTLCDestinationZ_free(self); } - COption_HTLCDestinationZ& operator=(COption_HTLCDestinationZ&& o) { COption_HTLCDestinationZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_HTLCDestinationZ)); return *this; } - LDKCOption_HTLCDestinationZ* operator &() { return &self; } - LDKCOption_HTLCDestinationZ* operator ->() { return &self; } - const LDKCOption_HTLCDestinationZ* operator &() const { return &self; } - const LDKCOption_HTLCDestinationZ* operator ->() const { return &self; } -}; -class C2Tuple_BlockHashChannelMonitorZ { +class CResult_boolLightningErrorZ { private: - LDKC2Tuple_BlockHashChannelMonitorZ self; + LDKCResult_boolLightningErrorZ self; public: - C2Tuple_BlockHashChannelMonitorZ(const C2Tuple_BlockHashChannelMonitorZ&) = delete; - C2Tuple_BlockHashChannelMonitorZ(C2Tuple_BlockHashChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); } - C2Tuple_BlockHashChannelMonitorZ(LDKC2Tuple_BlockHashChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); } - operator LDKC2Tuple_BlockHashChannelMonitorZ() && { LDKC2Tuple_BlockHashChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); return res; } - ~C2Tuple_BlockHashChannelMonitorZ() { C2Tuple_BlockHashChannelMonitorZ_free(self); } - C2Tuple_BlockHashChannelMonitorZ& operator=(C2Tuple_BlockHashChannelMonitorZ&& o) { C2Tuple_BlockHashChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); return *this; } - LDKC2Tuple_BlockHashChannelMonitorZ* operator &() { return &self; } - LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() { return &self; } - const LDKC2Tuple_BlockHashChannelMonitorZ* operator &() const { return &self; } - const LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() const { return &self; } + CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete; + CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); } + CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); } + operator LDKCResult_boolLightningErrorZ() && { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; } + ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); } + CResult_boolLightningErrorZ& operator=(CResult_boolLightningErrorZ&& o) { CResult_boolLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); return *this; } + LDKCResult_boolLightningErrorZ* operator &() { return &self; } + LDKCResult_boolLightningErrorZ* operator ->() { return &self; } + const LDKCResult_boolLightningErrorZ* operator &() const { return &self; } + const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; } }; -class CResult_ShutdownScriptInvalidShutdownScriptZ { +class CResult_ChannelShutdownStateDecodeErrorZ { private: - LDKCResult_ShutdownScriptInvalidShutdownScriptZ self; + LDKCResult_ChannelShutdownStateDecodeErrorZ self; public: - CResult_ShutdownScriptInvalidShutdownScriptZ(const CResult_ShutdownScriptInvalidShutdownScriptZ&) = delete; - CResult_ShutdownScriptInvalidShutdownScriptZ(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); } - CResult_ShutdownScriptInvalidShutdownScriptZ(LDKCResult_ShutdownScriptInvalidShutdownScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); } - operator LDKCResult_ShutdownScriptInvalidShutdownScriptZ() && { LDKCResult_ShutdownScriptInvalidShutdownScriptZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); return res; } - ~CResult_ShutdownScriptInvalidShutdownScriptZ() { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); } - CResult_ShutdownScriptInvalidShutdownScriptZ& operator=(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); return *this; } - LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() { return &self; } - LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() { return &self; } - const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() const { return &self; } - const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() const { return &self; } + CResult_ChannelShutdownStateDecodeErrorZ(const CResult_ChannelShutdownStateDecodeErrorZ&) = delete; + CResult_ChannelShutdownStateDecodeErrorZ(CResult_ChannelShutdownStateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelShutdownStateDecodeErrorZ)); } + CResult_ChannelShutdownStateDecodeErrorZ(LDKCResult_ChannelShutdownStateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ)); } + operator LDKCResult_ChannelShutdownStateDecodeErrorZ() && { LDKCResult_ChannelShutdownStateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ)); return res; } + ~CResult_ChannelShutdownStateDecodeErrorZ() { CResult_ChannelShutdownStateDecodeErrorZ_free(self); } + CResult_ChannelShutdownStateDecodeErrorZ& operator=(CResult_ChannelShutdownStateDecodeErrorZ&& o) { CResult_ChannelShutdownStateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelShutdownStateDecodeErrorZ)); return *this; } + LDKCResult_ChannelShutdownStateDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelShutdownStateDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelShutdownStateDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelShutdownStateDecodeErrorZ* operator ->() const { return &self; } }; class CResult_NodeAnnouncementInfoDecodeErrorZ { private: @@ -5488,6 +6378,21 @@ public: const LDKCResult_NodeAnnouncementInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAnnouncementInfoDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_BlockHashChannelMonitorZ { +private: + LDKC2Tuple_BlockHashChannelMonitorZ self; +public: + C2Tuple_BlockHashChannelMonitorZ(const C2Tuple_BlockHashChannelMonitorZ&) = delete; + C2Tuple_BlockHashChannelMonitorZ(C2Tuple_BlockHashChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); } + C2Tuple_BlockHashChannelMonitorZ(LDKC2Tuple_BlockHashChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); } + operator LDKC2Tuple_BlockHashChannelMonitorZ() && { LDKC2Tuple_BlockHashChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); return res; } + ~C2Tuple_BlockHashChannelMonitorZ() { C2Tuple_BlockHashChannelMonitorZ_free(self); } + C2Tuple_BlockHashChannelMonitorZ& operator=(C2Tuple_BlockHashChannelMonitorZ&& o) { C2Tuple_BlockHashChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); return *this; } + LDKC2Tuple_BlockHashChannelMonitorZ* operator &() { return &self; } + LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() { return &self; } + const LDKC2Tuple_BlockHashChannelMonitorZ* operator &() const { return &self; } + const LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() const { return &self; } +}; class CResult_COption_NetworkUpdateZDecodeErrorZ { private: LDKCResult_COption_NetworkUpdateZDecodeErrorZ self; @@ -5503,35 +6408,95 @@ public: const LDKCResult_COption_NetworkUpdateZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_NetworkUpdateZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_NoneRetryableSendFailureZ { +class CVec_UpdateFailMalformedHTLCZ { private: - LDKCResult_NoneRetryableSendFailureZ self; + LDKCVec_UpdateFailMalformedHTLCZ self; public: - CResult_NoneRetryableSendFailureZ(const CResult_NoneRetryableSendFailureZ&) = delete; - CResult_NoneRetryableSendFailureZ(CResult_NoneRetryableSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); } - CResult_NoneRetryableSendFailureZ(LDKCResult_NoneRetryableSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); } - operator LDKCResult_NoneRetryableSendFailureZ() && { LDKCResult_NoneRetryableSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); return res; } - ~CResult_NoneRetryableSendFailureZ() { CResult_NoneRetryableSendFailureZ_free(self); } - CResult_NoneRetryableSendFailureZ& operator=(CResult_NoneRetryableSendFailureZ&& o) { CResult_NoneRetryableSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); return *this; } - LDKCResult_NoneRetryableSendFailureZ* operator &() { return &self; } - LDKCResult_NoneRetryableSendFailureZ* operator ->() { return &self; } - const LDKCResult_NoneRetryableSendFailureZ* operator &() const { return &self; } - const LDKCResult_NoneRetryableSendFailureZ* operator ->() const { return &self; } + CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete; + CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); } + CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); } + operator LDKCVec_UpdateFailMalformedHTLCZ() && { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; } + ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); } + CVec_UpdateFailMalformedHTLCZ& operator=(CVec_UpdateFailMalformedHTLCZ&& o) { CVec_UpdateFailMalformedHTLCZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); return *this; } + LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; } + LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; } +}; +class CResult_ShutdownScriptNoneZ { +private: + LDKCResult_ShutdownScriptNoneZ self; +public: + CResult_ShutdownScriptNoneZ(const CResult_ShutdownScriptNoneZ&) = delete; + CResult_ShutdownScriptNoneZ(CResult_ShutdownScriptNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptNoneZ)); } + CResult_ShutdownScriptNoneZ(LDKCResult_ShutdownScriptNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptNoneZ)); } + operator LDKCResult_ShutdownScriptNoneZ() && { LDKCResult_ShutdownScriptNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptNoneZ)); return res; } + ~CResult_ShutdownScriptNoneZ() { CResult_ShutdownScriptNoneZ_free(self); } + CResult_ShutdownScriptNoneZ& operator=(CResult_ShutdownScriptNoneZ&& o) { CResult_ShutdownScriptNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptNoneZ)); return *this; } + LDKCResult_ShutdownScriptNoneZ* operator &() { return &self; } + LDKCResult_ShutdownScriptNoneZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptNoneZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptNoneZ* operator ->() const { return &self; } +}; +class CResult_HTLCOutputInCommitmentDecodeErrorZ { +private: + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self; +public: + CResult_HTLCOutputInCommitmentDecodeErrorZ(const CResult_HTLCOutputInCommitmentDecodeErrorZ&) = delete; + CResult_HTLCOutputInCommitmentDecodeErrorZ(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); } + CResult_HTLCOutputInCommitmentDecodeErrorZ(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); } + operator LDKCResult_HTLCOutputInCommitmentDecodeErrorZ() && { LDKCResult_HTLCOutputInCommitmentDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); return res; } + ~CResult_HTLCOutputInCommitmentDecodeErrorZ() { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); } + CResult_HTLCOutputInCommitmentDecodeErrorZ& operator=(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); return *this; } + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() { return &self; } + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_ShutdownScriptInvalidShutdownScriptZ { +private: + LDKCResult_ShutdownScriptInvalidShutdownScriptZ self; +public: + CResult_ShutdownScriptInvalidShutdownScriptZ(const CResult_ShutdownScriptInvalidShutdownScriptZ&) = delete; + CResult_ShutdownScriptInvalidShutdownScriptZ(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); } + CResult_ShutdownScriptInvalidShutdownScriptZ(LDKCResult_ShutdownScriptInvalidShutdownScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); } + operator LDKCResult_ShutdownScriptInvalidShutdownScriptZ() && { LDKCResult_ShutdownScriptInvalidShutdownScriptZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); return res; } + ~CResult_ShutdownScriptInvalidShutdownScriptZ() { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); } + CResult_ShutdownScriptInvalidShutdownScriptZ& operator=(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); return *this; } + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() { return &self; } + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() const { return &self; } +}; +class CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { +private: + LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ self; +public: + CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(const CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&) = delete; + CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); } + CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); } + operator LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ() && { LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); return res; } + ~CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ() { CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(self); } + CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ& operator=(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& o) { CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); return *this; } + LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator &() { return &self; } + LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator ->() const { return &self; } }; -class CVec_UpdateFailMalformedHTLCZ { +class COption_HTLCDestinationZ { private: - LDKCVec_UpdateFailMalformedHTLCZ self; + LDKCOption_HTLCDestinationZ self; public: - CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete; - CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); } - CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); } - operator LDKCVec_UpdateFailMalformedHTLCZ() && { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; } - ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); } - CVec_UpdateFailMalformedHTLCZ& operator=(CVec_UpdateFailMalformedHTLCZ&& o) { CVec_UpdateFailMalformedHTLCZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); return *this; } - LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; } - LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; } + COption_HTLCDestinationZ(const COption_HTLCDestinationZ&) = delete; + COption_HTLCDestinationZ(COption_HTLCDestinationZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_HTLCDestinationZ)); } + COption_HTLCDestinationZ(LDKCOption_HTLCDestinationZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_HTLCDestinationZ)); } + operator LDKCOption_HTLCDestinationZ() && { LDKCOption_HTLCDestinationZ res = self; memset(&self, 0, sizeof(LDKCOption_HTLCDestinationZ)); return res; } + ~COption_HTLCDestinationZ() { COption_HTLCDestinationZ_free(self); } + COption_HTLCDestinationZ& operator=(COption_HTLCDestinationZ&& o) { COption_HTLCDestinationZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_HTLCDestinationZ)); return *this; } + LDKCOption_HTLCDestinationZ* operator &() { return &self; } + LDKCOption_HTLCDestinationZ* operator ->() { return &self; } + const LDKCOption_HTLCDestinationZ* operator &() const { return &self; } + const LDKCOption_HTLCDestinationZ* operator ->() const { return &self; } }; class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { private: @@ -5548,21 +6513,6 @@ public: const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { -private: - LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ self; -public: - CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(const CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&) = delete; - CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); } - CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); } - operator LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ() && { LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); return res; } - ~CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ() { CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(self); } - CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ& operator=(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ&& o) { CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ)); return *this; } - LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ* operator ->() const { return &self; } -}; class CVec_RouteHopZ { private: LDKCVec_RouteHopZ self; @@ -5578,6 +6528,21 @@ public: const LDKCVec_RouteHopZ* operator &() const { return &self; } const LDKCVec_RouteHopZ* operator ->() const { return &self; } }; +class CResult_CVec_UtxoZNoneZ { +private: + LDKCResult_CVec_UtxoZNoneZ self; +public: + CResult_CVec_UtxoZNoneZ(const CResult_CVec_UtxoZNoneZ&) = delete; + CResult_CVec_UtxoZNoneZ(CResult_CVec_UtxoZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_UtxoZNoneZ)); } + CResult_CVec_UtxoZNoneZ(LDKCResult_CVec_UtxoZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_UtxoZNoneZ)); } + operator LDKCResult_CVec_UtxoZNoneZ() && { LDKCResult_CVec_UtxoZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_UtxoZNoneZ)); return res; } + ~CResult_CVec_UtxoZNoneZ() { CResult_CVec_UtxoZNoneZ_free(self); } + CResult_CVec_UtxoZNoneZ& operator=(CResult_CVec_UtxoZNoneZ&& o) { CResult_CVec_UtxoZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_UtxoZNoneZ)); return *this; } + LDKCResult_CVec_UtxoZNoneZ* operator &() { return &self; } + LDKCResult_CVec_UtxoZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_UtxoZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_UtxoZNoneZ* operator ->() const { return &self; } +}; class COption_CustomOnionMessageContentsZ { private: LDKCOption_CustomOnionMessageContentsZ self; @@ -5608,6 +6573,21 @@ public: const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator ->() const { return &self; } }; +class CResult_COption_KeyPairZNoneZ { +private: + LDKCResult_COption_KeyPairZNoneZ self; +public: + CResult_COption_KeyPairZNoneZ(const CResult_COption_KeyPairZNoneZ&) = delete; + CResult_COption_KeyPairZNoneZ(CResult_COption_KeyPairZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_KeyPairZNoneZ)); } + CResult_COption_KeyPairZNoneZ(LDKCResult_COption_KeyPairZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_KeyPairZNoneZ)); } + operator LDKCResult_COption_KeyPairZNoneZ() && { LDKCResult_COption_KeyPairZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_KeyPairZNoneZ)); return res; } + ~CResult_COption_KeyPairZNoneZ() { CResult_COption_KeyPairZNoneZ_free(self); } + CResult_COption_KeyPairZNoneZ& operator=(CResult_COption_KeyPairZNoneZ&& o) { CResult_COption_KeyPairZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_KeyPairZNoneZ)); return *this; } + LDKCResult_COption_KeyPairZNoneZ* operator &() { return &self; } + LDKCResult_COption_KeyPairZNoneZ* operator ->() { return &self; } + const LDKCResult_COption_KeyPairZNoneZ* operator &() const { return &self; } + const LDKCResult_COption_KeyPairZNoneZ* operator ->() const { return &self; } +}; class CVec_ThirtyTwoBytesZ { private: LDKCVec_ThirtyTwoBytesZ self; @@ -5743,6 +6723,21 @@ public: const LDKCResult_UntrustedStringDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UntrustedStringDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_U5Z { +private: + LDKCVec_U5Z self; +public: + CVec_U5Z(const CVec_U5Z&) = delete; + CVec_U5Z(CVec_U5Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_U5Z)); } + CVec_U5Z(LDKCVec_U5Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_U5Z)); } + operator LDKCVec_U5Z() && { LDKCVec_U5Z res = self; memset(&self, 0, sizeof(LDKCVec_U5Z)); return res; } + ~CVec_U5Z() { CVec_U5Z_free(self); } + CVec_U5Z& operator=(CVec_U5Z&& o) { CVec_U5Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_U5Z)); return *this; } + LDKCVec_U5Z* operator &() { return &self; } + LDKCVec_U5Z* operator ->() { return &self; } + const LDKCVec_U5Z* operator &() const { return &self; } + const LDKCVec_U5Z* operator ->() const { return &self; } +}; class CResult_PaymentParametersDecodeErrorZ { private: LDKCResult_PaymentParametersDecodeErrorZ self; @@ -5758,20 +6753,35 @@ public: const LDKCResult_PaymentParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PaymentParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_U5Z { +class CResult_TxAckRbfDecodeErrorZ { private: - LDKCVec_U5Z self; + LDKCResult_TxAckRbfDecodeErrorZ self; public: - CVec_U5Z(const CVec_U5Z&) = delete; - CVec_U5Z(CVec_U5Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_U5Z)); } - CVec_U5Z(LDKCVec_U5Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_U5Z)); } - operator LDKCVec_U5Z() && { LDKCVec_U5Z res = self; memset(&self, 0, sizeof(LDKCVec_U5Z)); return res; } - ~CVec_U5Z() { CVec_U5Z_free(self); } - CVec_U5Z& operator=(CVec_U5Z&& o) { CVec_U5Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_U5Z)); return *this; } - LDKCVec_U5Z* operator &() { return &self; } - LDKCVec_U5Z* operator ->() { return &self; } - const LDKCVec_U5Z* operator &() const { return &self; } - const LDKCVec_U5Z* operator ->() const { return &self; } + CResult_TxAckRbfDecodeErrorZ(const CResult_TxAckRbfDecodeErrorZ&) = delete; + CResult_TxAckRbfDecodeErrorZ(CResult_TxAckRbfDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAckRbfDecodeErrorZ)); } + CResult_TxAckRbfDecodeErrorZ(LDKCResult_TxAckRbfDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAckRbfDecodeErrorZ)); } + operator LDKCResult_TxAckRbfDecodeErrorZ() && { LDKCResult_TxAckRbfDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAckRbfDecodeErrorZ)); return res; } + ~CResult_TxAckRbfDecodeErrorZ() { CResult_TxAckRbfDecodeErrorZ_free(self); } + CResult_TxAckRbfDecodeErrorZ& operator=(CResult_TxAckRbfDecodeErrorZ&& o) { CResult_TxAckRbfDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAckRbfDecodeErrorZ)); return *this; } + LDKCResult_TxAckRbfDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxAckRbfDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxAckRbfDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxAckRbfDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_Bolt11InvoiceBolt11SemanticErrorZ { +private: + LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ self; +public: + CResult_Bolt11InvoiceBolt11SemanticErrorZ(const CResult_Bolt11InvoiceBolt11SemanticErrorZ&) = delete; + CResult_Bolt11InvoiceBolt11SemanticErrorZ(CResult_Bolt11InvoiceBolt11SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt11InvoiceBolt11SemanticErrorZ)); } + CResult_Bolt11InvoiceBolt11SemanticErrorZ(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ)); } + operator LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ() && { LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ)); return res; } + ~CResult_Bolt11InvoiceBolt11SemanticErrorZ() { CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(self); } + CResult_Bolt11InvoiceBolt11SemanticErrorZ& operator=(CResult_Bolt11InvoiceBolt11SemanticErrorZ&& o) { CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt11InvoiceBolt11SemanticErrorZ)); return *this; } + LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* operator &() { return &self; } + LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* operator ->() const { return &self; } }; class COption_UtxoLookupZ { private: @@ -5923,21 +6933,6 @@ public: const LDKC2Tuple_PaymentHashPaymentIdZ* operator &() const { return &self; } const LDKC2Tuple_PaymentHashPaymentIdZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { -private: - LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ self; -public: - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ(const CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ&) = delete; - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ(CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ)); } - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ)); } - operator LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ() && { LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ)); return res; } - ~CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ() { CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(self); } - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ& operator=(CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ&& o) { CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ)); return *this; } - LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator &() { return &self; } - LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator ->() const { return &self; } -}; class CResult_NoneErrorZ { private: LDKCResult_NoneErrorZ self; @@ -5983,20 +6978,20 @@ public: const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_SiPrefixParseErrorZ { +class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { private: - LDKCResult_SiPrefixParseErrorZ self; + LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ self; public: - CResult_SiPrefixParseErrorZ(const CResult_SiPrefixParseErrorZ&) = delete; - CResult_SiPrefixParseErrorZ(CResult_SiPrefixParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixParseErrorZ)); } - CResult_SiPrefixParseErrorZ(LDKCResult_SiPrefixParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixParseErrorZ)); } - operator LDKCResult_SiPrefixParseErrorZ() && { LDKCResult_SiPrefixParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixParseErrorZ)); return res; } - ~CResult_SiPrefixParseErrorZ() { CResult_SiPrefixParseErrorZ_free(self); } - CResult_SiPrefixParseErrorZ& operator=(CResult_SiPrefixParseErrorZ&& o) { CResult_SiPrefixParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixParseErrorZ)); return *this; } - LDKCResult_SiPrefixParseErrorZ* operator &() { return &self; } - LDKCResult_SiPrefixParseErrorZ* operator ->() { return &self; } - const LDKCResult_SiPrefixParseErrorZ* operator &() const { return &self; } - const LDKCResult_SiPrefixParseErrorZ* operator ->() const { return &self; } + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ(const C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ&) = delete; + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ(C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ)); } + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ)); } + operator LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ() && { LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ)); return res; } + ~C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ() { C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(self); } + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ& operator=(C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ&& o) { C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ)); return *this; } + LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* operator &() { return &self; } + LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* operator ->() { return &self; } + const LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* operator &() const { return &self; } + const LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* operator ->() const { return &self; } }; class CResult_BlindedHopDecodeErrorZ { private: @@ -6013,20 +7008,20 @@ public: const LDKCResult_BlindedHopDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedHopDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_TrustedCommitmentTransactionNoneZ { +class CResult_NoneLightningErrorZ { private: - LDKCResult_TrustedCommitmentTransactionNoneZ self; + LDKCResult_NoneLightningErrorZ self; public: - CResult_TrustedCommitmentTransactionNoneZ(const CResult_TrustedCommitmentTransactionNoneZ&) = delete; - CResult_TrustedCommitmentTransactionNoneZ(CResult_TrustedCommitmentTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); } - CResult_TrustedCommitmentTransactionNoneZ(LDKCResult_TrustedCommitmentTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); } - operator LDKCResult_TrustedCommitmentTransactionNoneZ() && { LDKCResult_TrustedCommitmentTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); return res; } - ~CResult_TrustedCommitmentTransactionNoneZ() { CResult_TrustedCommitmentTransactionNoneZ_free(self); } - CResult_TrustedCommitmentTransactionNoneZ& operator=(CResult_TrustedCommitmentTransactionNoneZ&& o) { CResult_TrustedCommitmentTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); return *this; } - LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() { return &self; } - LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() { return &self; } - const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } - const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } + CResult_NoneLightningErrorZ(const CResult_NoneLightningErrorZ&) = delete; + CResult_NoneLightningErrorZ(CResult_NoneLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); } + CResult_NoneLightningErrorZ(LDKCResult_NoneLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); } + operator LDKCResult_NoneLightningErrorZ() && { LDKCResult_NoneLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); return res; } + ~CResult_NoneLightningErrorZ() { CResult_NoneLightningErrorZ_free(self); } + CResult_NoneLightningErrorZ& operator=(CResult_NoneLightningErrorZ&& o) { CResult_NoneLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); return *this; } + LDKCResult_NoneLightningErrorZ* operator &() { return &self; } + LDKCResult_NoneLightningErrorZ* operator ->() { return &self; } + const LDKCResult_NoneLightningErrorZ* operator &() const { return &self; } + const LDKCResult_NoneLightningErrorZ* operator ->() const { return &self; } }; class CResult_FixedPenaltyScorerDecodeErrorZ { private: @@ -6058,21 +7053,6 @@ public: const LDKCVec_BlindedPathZ* operator &() const { return &self; } const LDKCVec_BlindedPathZ* operator ->() const { return &self; } }; -class CResult_NoneLightningErrorZ { -private: - LDKCResult_NoneLightningErrorZ self; -public: - CResult_NoneLightningErrorZ(const CResult_NoneLightningErrorZ&) = delete; - CResult_NoneLightningErrorZ(CResult_NoneLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); } - CResult_NoneLightningErrorZ(LDKCResult_NoneLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); } - operator LDKCResult_NoneLightningErrorZ() && { LDKCResult_NoneLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneLightningErrorZ)); return res; } - ~CResult_NoneLightningErrorZ() { CResult_NoneLightningErrorZ_free(self); } - CResult_NoneLightningErrorZ& operator=(CResult_NoneLightningErrorZ&& o) { CResult_NoneLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneLightningErrorZ)); return *this; } - LDKCResult_NoneLightningErrorZ* operator &() { return &self; } - LDKCResult_NoneLightningErrorZ* operator ->() { return &self; } - const LDKCResult_NoneLightningErrorZ* operator &() const { return &self; } - const LDKCResult_NoneLightningErrorZ* operator ->() const { return &self; } -}; class CResult_PaymentHashRetryableSendFailureZ { private: LDKCResult_PaymentHashRetryableSendFailureZ self; @@ -6088,35 +7068,20 @@ public: const LDKCResult_PaymentHashRetryableSendFailureZ* operator &() const { return &self; } const LDKCResult_PaymentHashRetryableSendFailureZ* operator ->() const { return &self; } }; -class CResult_COption_EventZDecodeErrorZ { -private: - LDKCResult_COption_EventZDecodeErrorZ self; -public: - CResult_COption_EventZDecodeErrorZ(const CResult_COption_EventZDecodeErrorZ&) = delete; - CResult_COption_EventZDecodeErrorZ(CResult_COption_EventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); } - CResult_COption_EventZDecodeErrorZ(LDKCResult_COption_EventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); } - operator LDKCResult_COption_EventZDecodeErrorZ() && { LDKCResult_COption_EventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); return res; } - ~CResult_COption_EventZDecodeErrorZ() { CResult_COption_EventZDecodeErrorZ_free(self); } - CResult_COption_EventZDecodeErrorZ& operator=(CResult_COption_EventZDecodeErrorZ&& o) { CResult_COption_EventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); return *this; } - LDKCResult_COption_EventZDecodeErrorZ* operator &() { return &self; } - LDKCResult_COption_EventZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } -}; -class CResult_CVec_SignatureZNoneZ { +class C2Tuple_PublicKeyCOption_NetAddressZZ { private: - LDKCResult_CVec_SignatureZNoneZ self; + LDKC2Tuple_PublicKeyCOption_NetAddressZZ self; public: - CResult_CVec_SignatureZNoneZ(const CResult_CVec_SignatureZNoneZ&) = delete; - CResult_CVec_SignatureZNoneZ(CResult_CVec_SignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); } - CResult_CVec_SignatureZNoneZ(LDKCResult_CVec_SignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); } - operator LDKCResult_CVec_SignatureZNoneZ() && { LDKCResult_CVec_SignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); return res; } - ~CResult_CVec_SignatureZNoneZ() { CResult_CVec_SignatureZNoneZ_free(self); } - CResult_CVec_SignatureZNoneZ& operator=(CResult_CVec_SignatureZNoneZ&& o) { CResult_CVec_SignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); return *this; } - LDKCResult_CVec_SignatureZNoneZ* operator &() { return &self; } - LDKCResult_CVec_SignatureZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; } + C2Tuple_PublicKeyCOption_NetAddressZZ(const C2Tuple_PublicKeyCOption_NetAddressZZ&) = delete; + C2Tuple_PublicKeyCOption_NetAddressZZ(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); } + C2Tuple_PublicKeyCOption_NetAddressZZ(LDKC2Tuple_PublicKeyCOption_NetAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); } + operator LDKC2Tuple_PublicKeyCOption_NetAddressZZ() && { LDKC2Tuple_PublicKeyCOption_NetAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); return res; } + ~C2Tuple_PublicKeyCOption_NetAddressZZ() { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); } + C2Tuple_PublicKeyCOption_NetAddressZZ& operator=(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); return *this; } + LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() { return &self; } + LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() { return &self; } + const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() const { return &self; } + const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() const { return &self; } }; class COption_CVec_NetAddressZZ { private: @@ -6133,6 +7098,51 @@ public: const LDKCOption_CVec_NetAddressZZ* operator &() const { return &self; } const LDKCOption_CVec_NetAddressZZ* operator ->() const { return &self; } }; +class CResult_NonePeerHandleErrorZ { +private: + LDKCResult_NonePeerHandleErrorZ self; +public: + CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; + CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } + CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } + operator LDKCResult_NonePeerHandleErrorZ() && { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } + ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } + CResult_NonePeerHandleErrorZ& operator=(CResult_NonePeerHandleErrorZ&& o) { CResult_NonePeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); return *this; } + LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } + LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } +}; +class CResult_TrustedCommitmentTransactionNoneZ { +private: + LDKCResult_TrustedCommitmentTransactionNoneZ self; +public: + CResult_TrustedCommitmentTransactionNoneZ(const CResult_TrustedCommitmentTransactionNoneZ&) = delete; + CResult_TrustedCommitmentTransactionNoneZ(CResult_TrustedCommitmentTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); } + CResult_TrustedCommitmentTransactionNoneZ(LDKCResult_TrustedCommitmentTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); } + operator LDKCResult_TrustedCommitmentTransactionNoneZ() && { LDKCResult_TrustedCommitmentTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ)); return res; } + ~CResult_TrustedCommitmentTransactionNoneZ() { CResult_TrustedCommitmentTransactionNoneZ_free(self); } + CResult_TrustedCommitmentTransactionNoneZ& operator=(CResult_TrustedCommitmentTransactionNoneZ&& o) { CResult_TrustedCommitmentTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedCommitmentTransactionNoneZ)); return *this; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() { return &self; } + LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } +}; +class CResult_CVec_SignatureZNoneZ { +private: + LDKCResult_CVec_SignatureZNoneZ self; +public: + CResult_CVec_SignatureZNoneZ(const CResult_CVec_SignatureZNoneZ&) = delete; + CResult_CVec_SignatureZNoneZ(CResult_CVec_SignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); } + CResult_CVec_SignatureZNoneZ(LDKCResult_CVec_SignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); } + operator LDKCResult_CVec_SignatureZNoneZ() && { LDKCResult_CVec_SignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); return res; } + ~CResult_CVec_SignatureZNoneZ() { CResult_CVec_SignatureZNoneZ_free(self); } + CResult_CVec_SignatureZNoneZ& operator=(CResult_CVec_SignatureZNoneZ&& o) { CResult_CVec_SignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); return *this; } + LDKCResult_CVec_SignatureZNoneZ* operator &() { return &self; } + LDKCResult_CVec_SignatureZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; } +}; class CResult_PaymentFailureReasonDecodeErrorZ { private: LDKCResult_PaymentFailureReasonDecodeErrorZ self; @@ -6148,50 +7158,20 @@ public: const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_PublicKeyCOption_NetAddressZZ { -private: - LDKC2Tuple_PublicKeyCOption_NetAddressZZ self; -public: - C2Tuple_PublicKeyCOption_NetAddressZZ(const C2Tuple_PublicKeyCOption_NetAddressZZ&) = delete; - C2Tuple_PublicKeyCOption_NetAddressZZ(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); } - C2Tuple_PublicKeyCOption_NetAddressZZ(LDKC2Tuple_PublicKeyCOption_NetAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); } - operator LDKC2Tuple_PublicKeyCOption_NetAddressZZ() && { LDKC2Tuple_PublicKeyCOption_NetAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); return res; } - ~C2Tuple_PublicKeyCOption_NetAddressZZ() { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); } - C2Tuple_PublicKeyCOption_NetAddressZZ& operator=(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); return *this; } - LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() { return &self; } - LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() { return &self; } - const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() const { return &self; } - const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() const { return &self; } -}; class CResult__u832APIErrorZ { -private: - LDKCResult__u832APIErrorZ self; -public: - CResult__u832APIErrorZ(const CResult__u832APIErrorZ&) = delete; - CResult__u832APIErrorZ(CResult__u832APIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult__u832APIErrorZ)); } - CResult__u832APIErrorZ(LDKCResult__u832APIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult__u832APIErrorZ)); } - operator LDKCResult__u832APIErrorZ() && { LDKCResult__u832APIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult__u832APIErrorZ)); return res; } - ~CResult__u832APIErrorZ() { CResult__u832APIErrorZ_free(self); } - CResult__u832APIErrorZ& operator=(CResult__u832APIErrorZ&& o) { CResult__u832APIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult__u832APIErrorZ)); return *this; } - LDKCResult__u832APIErrorZ* operator &() { return &self; } - LDKCResult__u832APIErrorZ* operator ->() { return &self; } - const LDKCResult__u832APIErrorZ* operator &() const { return &self; } - const LDKCResult__u832APIErrorZ* operator ->() const { return &self; } -}; -class CResult_PaymentIdPaymentErrorZ { -private: - LDKCResult_PaymentIdPaymentErrorZ self; -public: - CResult_PaymentIdPaymentErrorZ(const CResult_PaymentIdPaymentErrorZ&) = delete; - CResult_PaymentIdPaymentErrorZ(CResult_PaymentIdPaymentErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentIdPaymentErrorZ)); } - CResult_PaymentIdPaymentErrorZ(LDKCResult_PaymentIdPaymentErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentIdPaymentErrorZ)); } - operator LDKCResult_PaymentIdPaymentErrorZ() && { LDKCResult_PaymentIdPaymentErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentIdPaymentErrorZ)); return res; } - ~CResult_PaymentIdPaymentErrorZ() { CResult_PaymentIdPaymentErrorZ_free(self); } - CResult_PaymentIdPaymentErrorZ& operator=(CResult_PaymentIdPaymentErrorZ&& o) { CResult_PaymentIdPaymentErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentIdPaymentErrorZ)); return *this; } - LDKCResult_PaymentIdPaymentErrorZ* operator &() { return &self; } - LDKCResult_PaymentIdPaymentErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentIdPaymentErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentIdPaymentErrorZ* operator ->() const { return &self; } +private: + LDKCResult__u832APIErrorZ self; +public: + CResult__u832APIErrorZ(const CResult__u832APIErrorZ&) = delete; + CResult__u832APIErrorZ(CResult__u832APIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult__u832APIErrorZ)); } + CResult__u832APIErrorZ(LDKCResult__u832APIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult__u832APIErrorZ)); } + operator LDKCResult__u832APIErrorZ() && { LDKCResult__u832APIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult__u832APIErrorZ)); return res; } + ~CResult__u832APIErrorZ() { CResult__u832APIErrorZ_free(self); } + CResult__u832APIErrorZ& operator=(CResult__u832APIErrorZ&& o) { CResult__u832APIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult__u832APIErrorZ)); return *this; } + LDKCResult__u832APIErrorZ* operator &() { return &self; } + LDKCResult__u832APIErrorZ* operator ->() { return &self; } + const LDKCResult__u832APIErrorZ* operator &() const { return &self; } + const LDKCResult__u832APIErrorZ* operator ->() const { return &self; } }; class CResult_COption_MonitorEventZDecodeErrorZ { private: @@ -6208,6 +7188,21 @@ public: const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_MonitorEventZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_COption_EventZDecodeErrorZ { +private: + LDKCResult_COption_EventZDecodeErrorZ self; +public: + CResult_COption_EventZDecodeErrorZ(const CResult_COption_EventZDecodeErrorZ&) = delete; + CResult_COption_EventZDecodeErrorZ(CResult_COption_EventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); } + CResult_COption_EventZDecodeErrorZ(LDKCResult_COption_EventZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); } + operator LDKCResult_COption_EventZDecodeErrorZ() && { LDKCResult_COption_EventZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_EventZDecodeErrorZ)); return res; } + ~CResult_COption_EventZDecodeErrorZ() { CResult_COption_EventZDecodeErrorZ_free(self); } + CResult_COption_EventZDecodeErrorZ& operator=(CResult_COption_EventZDecodeErrorZ&& o) { CResult_COption_EventZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); return *this; } + LDKCResult_COption_EventZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_EventZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RoutingFeesDecodeErrorZ { private: LDKCResult_RoutingFeesDecodeErrorZ self; @@ -6223,21 +7218,6 @@ public: const LDKCResult_RoutingFeesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RoutingFeesDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_NonePeerHandleErrorZ { -private: - LDKCResult_NonePeerHandleErrorZ self; -public: - CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; - CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } - CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } - operator LDKCResult_NonePeerHandleErrorZ() && { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } - ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } - CResult_NonePeerHandleErrorZ& operator=(CResult_NonePeerHandleErrorZ&& o) { CResult_NonePeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); return *this; } - LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } - LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } -}; class CResult_PayeePubKeyErrorZ { private: LDKCResult_PayeePubKeyErrorZ self; @@ -6268,6 +7248,21 @@ public: const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; } const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; } }; +class CResult_PaymentIdPaymentErrorZ { +private: + LDKCResult_PaymentIdPaymentErrorZ self; +public: + CResult_PaymentIdPaymentErrorZ(const CResult_PaymentIdPaymentErrorZ&) = delete; + CResult_PaymentIdPaymentErrorZ(CResult_PaymentIdPaymentErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentIdPaymentErrorZ)); } + CResult_PaymentIdPaymentErrorZ(LDKCResult_PaymentIdPaymentErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentIdPaymentErrorZ)); } + operator LDKCResult_PaymentIdPaymentErrorZ() && { LDKCResult_PaymentIdPaymentErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentIdPaymentErrorZ)); return res; } + ~CResult_PaymentIdPaymentErrorZ() { CResult_PaymentIdPaymentErrorZ_free(self); } + CResult_PaymentIdPaymentErrorZ& operator=(CResult_PaymentIdPaymentErrorZ&& o) { CResult_PaymentIdPaymentErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentIdPaymentErrorZ)); return *this; } + LDKCResult_PaymentIdPaymentErrorZ* operator &() { return &self; } + LDKCResult_PaymentIdPaymentErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentIdPaymentErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentIdPaymentErrorZ* operator ->() const { return &self; } +}; class CResult_QueryShortChannelIdsDecodeErrorZ { private: LDKCResult_QueryShortChannelIdsDecodeErrorZ self; @@ -6283,21 +7278,6 @@ public: const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceSemanticErrorZ { -private: - LDKCResult_InvoiceSemanticErrorZ self; -public: - CResult_InvoiceSemanticErrorZ(const CResult_InvoiceSemanticErrorZ&) = delete; - CResult_InvoiceSemanticErrorZ(CResult_InvoiceSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); } - CResult_InvoiceSemanticErrorZ(LDKCResult_InvoiceSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); } - operator LDKCResult_InvoiceSemanticErrorZ() && { LDKCResult_InvoiceSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); return res; } - ~CResult_InvoiceSemanticErrorZ() { CResult_InvoiceSemanticErrorZ_free(self); } - CResult_InvoiceSemanticErrorZ& operator=(CResult_InvoiceSemanticErrorZ&& o) { CResult_InvoiceSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); return *this; } - LDKCResult_InvoiceSemanticErrorZ* operator &() { return &self; } - LDKCResult_InvoiceSemanticErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceSemanticErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceSemanticErrorZ* operator ->() const { return &self; } -}; class CResult_UpdateAddHTLCDecodeErrorZ { private: LDKCResult_UpdateAddHTLCDecodeErrorZ self; @@ -6328,6 +7308,21 @@ public: const LDKCOption_MonitorEventZ* operator &() const { return &self; } const LDKCOption_MonitorEventZ* operator ->() const { return &self; } }; +class COption_CVec_ChainHashZZ { +private: + LDKCOption_CVec_ChainHashZZ self; +public: + COption_CVec_ChainHashZZ(const COption_CVec_ChainHashZZ&) = delete; + COption_CVec_ChainHashZZ(COption_CVec_ChainHashZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_CVec_ChainHashZZ)); } + COption_CVec_ChainHashZZ(LDKCOption_CVec_ChainHashZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_CVec_ChainHashZZ)); } + operator LDKCOption_CVec_ChainHashZZ() && { LDKCOption_CVec_ChainHashZZ res = self; memset(&self, 0, sizeof(LDKCOption_CVec_ChainHashZZ)); return res; } + ~COption_CVec_ChainHashZZ() { COption_CVec_ChainHashZZ_free(self); } + COption_CVec_ChainHashZZ& operator=(COption_CVec_ChainHashZZ&& o) { COption_CVec_ChainHashZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_CVec_ChainHashZZ)); return *this; } + LDKCOption_CVec_ChainHashZZ* operator &() { return &self; } + LDKCOption_CVec_ChainHashZZ* operator ->() { return &self; } + const LDKCOption_CVec_ChainHashZZ* operator &() const { return &self; } + const LDKCOption_CVec_ChainHashZZ* operator ->() const { return &self; } +}; class COption_TypeZ { private: LDKCOption_TypeZ self; @@ -6358,20 +7353,50 @@ public: const LDKCResult_COption_TypeZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_TypeZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_COption_PathFailureZDecodeErrorZ { -private: - LDKCResult_COption_PathFailureZDecodeErrorZ self; -public: - CResult_COption_PathFailureZDecodeErrorZ(const CResult_COption_PathFailureZDecodeErrorZ&) = delete; - CResult_COption_PathFailureZDecodeErrorZ(CResult_COption_PathFailureZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_PathFailureZDecodeErrorZ)); } - CResult_COption_PathFailureZDecodeErrorZ(LDKCResult_COption_PathFailureZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ)); } - operator LDKCResult_COption_PathFailureZDecodeErrorZ() && { LDKCResult_COption_PathFailureZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ)); return res; } - ~CResult_COption_PathFailureZDecodeErrorZ() { CResult_COption_PathFailureZDecodeErrorZ_free(self); } - CResult_COption_PathFailureZDecodeErrorZ& operator=(CResult_COption_PathFailureZDecodeErrorZ&& o) { CResult_COption_PathFailureZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_PathFailureZDecodeErrorZ)); return *this; } - LDKCResult_COption_PathFailureZDecodeErrorZ* operator &() { return &self; } - LDKCResult_COption_PathFailureZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_COption_PathFailureZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_COption_PathFailureZDecodeErrorZ* operator ->() const { return &self; } +class COption_KeyPairZ { +private: + LDKCOption_KeyPairZ self; +public: + COption_KeyPairZ(const COption_KeyPairZ&) = delete; + COption_KeyPairZ(COption_KeyPairZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_KeyPairZ)); } + COption_KeyPairZ(LDKCOption_KeyPairZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_KeyPairZ)); } + operator LDKCOption_KeyPairZ() && { LDKCOption_KeyPairZ res = self; memset(&self, 0, sizeof(LDKCOption_KeyPairZ)); return res; } + ~COption_KeyPairZ() { COption_KeyPairZ_free(self); } + COption_KeyPairZ& operator=(COption_KeyPairZ&& o) { COption_KeyPairZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_KeyPairZ)); return *this; } + LDKCOption_KeyPairZ* operator &() { return &self; } + LDKCOption_KeyPairZ* operator ->() { return &self; } + const LDKCOption_KeyPairZ* operator &() const { return &self; } + const LDKCOption_KeyPairZ* operator ->() const { return &self; } +}; +class CResult_Bolt11InvoiceSignOrCreationErrorZ { +private: + LDKCResult_Bolt11InvoiceSignOrCreationErrorZ self; +public: + CResult_Bolt11InvoiceSignOrCreationErrorZ(const CResult_Bolt11InvoiceSignOrCreationErrorZ&) = delete; + CResult_Bolt11InvoiceSignOrCreationErrorZ(CResult_Bolt11InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt11InvoiceSignOrCreationErrorZ)); } + CResult_Bolt11InvoiceSignOrCreationErrorZ(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ)); } + operator LDKCResult_Bolt11InvoiceSignOrCreationErrorZ() && { LDKCResult_Bolt11InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ)); return res; } + ~CResult_Bolt11InvoiceSignOrCreationErrorZ() { CResult_Bolt11InvoiceSignOrCreationErrorZ_free(self); } + CResult_Bolt11InvoiceSignOrCreationErrorZ& operator=(CResult_Bolt11InvoiceSignOrCreationErrorZ&& o) { CResult_Bolt11InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt11InvoiceSignOrCreationErrorZ)); return *this; } + LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator &() { return &self; } + LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } +}; +class COption_ScriptZ { +private: + LDKCOption_ScriptZ self; +public: + COption_ScriptZ(const COption_ScriptZ&) = delete; + COption_ScriptZ(COption_ScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ScriptZ)); } + COption_ScriptZ(LDKCOption_ScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ScriptZ)); } + operator LDKCOption_ScriptZ() && { LDKCOption_ScriptZ res = self; memset(&self, 0, sizeof(LDKCOption_ScriptZ)); return res; } + ~COption_ScriptZ() { COption_ScriptZ_free(self); } + COption_ScriptZ& operator=(COption_ScriptZ&& o) { COption_ScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ScriptZ)); return *this; } + LDKCOption_ScriptZ* operator &() { return &self; } + LDKCOption_ScriptZ* operator ->() { return &self; } + const LDKCOption_ScriptZ* operator &() const { return &self; } + const LDKCOption_ScriptZ* operator ->() const { return &self; } }; class CResult_UpdateFailHTLCDecodeErrorZ { private: @@ -6388,20 +7413,20 @@ public: const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceParseOrSemanticErrorZ { +class CResult_COption_PathFailureZDecodeErrorZ { private: - LDKCResult_InvoiceParseOrSemanticErrorZ self; + LDKCResult_COption_PathFailureZDecodeErrorZ self; public: - CResult_InvoiceParseOrSemanticErrorZ(const CResult_InvoiceParseOrSemanticErrorZ&) = delete; - CResult_InvoiceParseOrSemanticErrorZ(CResult_InvoiceParseOrSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceParseOrSemanticErrorZ)); } - CResult_InvoiceParseOrSemanticErrorZ(LDKCResult_InvoiceParseOrSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ)); } - operator LDKCResult_InvoiceParseOrSemanticErrorZ() && { LDKCResult_InvoiceParseOrSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ)); return res; } - ~CResult_InvoiceParseOrSemanticErrorZ() { CResult_InvoiceParseOrSemanticErrorZ_free(self); } - CResult_InvoiceParseOrSemanticErrorZ& operator=(CResult_InvoiceParseOrSemanticErrorZ&& o) { CResult_InvoiceParseOrSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceParseOrSemanticErrorZ)); return *this; } - LDKCResult_InvoiceParseOrSemanticErrorZ* operator &() { return &self; } - LDKCResult_InvoiceParseOrSemanticErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceParseOrSemanticErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceParseOrSemanticErrorZ* operator ->() const { return &self; } + CResult_COption_PathFailureZDecodeErrorZ(const CResult_COption_PathFailureZDecodeErrorZ&) = delete; + CResult_COption_PathFailureZDecodeErrorZ(CResult_COption_PathFailureZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_PathFailureZDecodeErrorZ)); } + CResult_COption_PathFailureZDecodeErrorZ(LDKCResult_COption_PathFailureZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ)); } + operator LDKCResult_COption_PathFailureZDecodeErrorZ() && { LDKCResult_COption_PathFailureZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ)); return res; } + ~CResult_COption_PathFailureZDecodeErrorZ() { CResult_COption_PathFailureZDecodeErrorZ_free(self); } + CResult_COption_PathFailureZDecodeErrorZ& operator=(CResult_COption_PathFailureZDecodeErrorZ&& o) { CResult_COption_PathFailureZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_PathFailureZDecodeErrorZ)); return *this; } + LDKCResult_COption_PathFailureZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_PathFailureZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_PathFailureZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_PathFailureZDecodeErrorZ* operator ->() const { return &self; } }; class CResult_RevokeAndACKDecodeErrorZ { private: @@ -6448,36 +7473,6 @@ public: const LDKCResult_UnsignedChannelUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedChannelUpdateDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_EventZ { -private: - LDKCVec_EventZ self; -public: - CVec_EventZ(const CVec_EventZ&) = delete; - CVec_EventZ(CVec_EventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_EventZ)); } - CVec_EventZ(LDKCVec_EventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_EventZ)); } - operator LDKCVec_EventZ() && { LDKCVec_EventZ res = self; memset(&self, 0, sizeof(LDKCVec_EventZ)); return res; } - ~CVec_EventZ() { CVec_EventZ_free(self); } - CVec_EventZ& operator=(CVec_EventZ&& o) { CVec_EventZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_EventZ)); return *this; } - LDKCVec_EventZ* operator &() { return &self; } - LDKCVec_EventZ* operator ->() { return &self; } - const LDKCVec_EventZ* operator &() const { return &self; } - const LDKCVec_EventZ* operator ->() const { return &self; } -}; -class CResult_NoneSemanticErrorZ { -private: - LDKCResult_NoneSemanticErrorZ self; -public: - CResult_NoneSemanticErrorZ(const CResult_NoneSemanticErrorZ&) = delete; - CResult_NoneSemanticErrorZ(CResult_NoneSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneSemanticErrorZ)); } - CResult_NoneSemanticErrorZ(LDKCResult_NoneSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneSemanticErrorZ)); } - operator LDKCResult_NoneSemanticErrorZ() && { LDKCResult_NoneSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneSemanticErrorZ)); return res; } - ~CResult_NoneSemanticErrorZ() { CResult_NoneSemanticErrorZ_free(self); } - CResult_NoneSemanticErrorZ& operator=(CResult_NoneSemanticErrorZ&& o) { CResult_NoneSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneSemanticErrorZ)); return *this; } - LDKCResult_NoneSemanticErrorZ* operator &() { return &self; } - LDKCResult_NoneSemanticErrorZ* operator ->() { return &self; } - const LDKCResult_NoneSemanticErrorZ* operator &() const { return &self; } - const LDKCResult_NoneSemanticErrorZ* operator ->() const { return &self; } -}; class CVec_C2Tuple_u32ScriptZZ { private: LDKCVec_C2Tuple_u32ScriptZZ self; @@ -6493,6 +7488,21 @@ public: const LDKCVec_C2Tuple_u32ScriptZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32ScriptZZ* operator ->() const { return &self; } }; +class CResult_InvoiceErrorDecodeErrorZ { +private: + LDKCResult_InvoiceErrorDecodeErrorZ self; +public: + CResult_InvoiceErrorDecodeErrorZ(const CResult_InvoiceErrorDecodeErrorZ&) = delete; + CResult_InvoiceErrorDecodeErrorZ(CResult_InvoiceErrorDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); } + CResult_InvoiceErrorDecodeErrorZ(LDKCResult_InvoiceErrorDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); } + operator LDKCResult_InvoiceErrorDecodeErrorZ() && { LDKCResult_InvoiceErrorDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); return res; } + ~CResult_InvoiceErrorDecodeErrorZ() { CResult_InvoiceErrorDecodeErrorZ_free(self); } + CResult_InvoiceErrorDecodeErrorZ& operator=(CResult_InvoiceErrorDecodeErrorZ&& o) { CResult_InvoiceErrorDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); return *this; } + LDKCResult_InvoiceErrorDecodeErrorZ* operator &() { return &self; } + LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceErrorDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_BlindedHopZ { private: LDKCVec_BlindedHopZ self; @@ -6508,21 +7518,6 @@ public: const LDKCVec_BlindedHopZ* operator &() const { return &self; } const LDKCVec_BlindedHopZ* operator ->() const { return &self; } }; -class CResult_COption_ClosureReasonZDecodeErrorZ { -private: - LDKCResult_COption_ClosureReasonZDecodeErrorZ self; -public: - CResult_COption_ClosureReasonZDecodeErrorZ(const CResult_COption_ClosureReasonZDecodeErrorZ&) = delete; - CResult_COption_ClosureReasonZDecodeErrorZ(CResult_COption_ClosureReasonZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_ClosureReasonZDecodeErrorZ)); } - CResult_COption_ClosureReasonZDecodeErrorZ(LDKCResult_COption_ClosureReasonZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ)); } - operator LDKCResult_COption_ClosureReasonZDecodeErrorZ() && { LDKCResult_COption_ClosureReasonZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ)); return res; } - ~CResult_COption_ClosureReasonZDecodeErrorZ() { CResult_COption_ClosureReasonZDecodeErrorZ_free(self); } - CResult_COption_ClosureReasonZDecodeErrorZ& operator=(CResult_COption_ClosureReasonZDecodeErrorZ&& o) { CResult_COption_ClosureReasonZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_ClosureReasonZDecodeErrorZ)); return *this; } - LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() { return &self; } - LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_PaymentHashPaymentSendFailureZ { private: LDKCResult_PaymentHashPaymentSendFailureZ self; @@ -6538,6 +7533,21 @@ public: const LDKCResult_PaymentHashPaymentSendFailureZ* operator &() const { return &self; } const LDKCResult_PaymentHashPaymentSendFailureZ* operator ->() const { return &self; } }; +class CResult_COption_ClosureReasonZDecodeErrorZ { +private: + LDKCResult_COption_ClosureReasonZDecodeErrorZ self; +public: + CResult_COption_ClosureReasonZDecodeErrorZ(const CResult_COption_ClosureReasonZDecodeErrorZ&) = delete; + CResult_COption_ClosureReasonZDecodeErrorZ(CResult_COption_ClosureReasonZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_ClosureReasonZDecodeErrorZ)); } + CResult_COption_ClosureReasonZDecodeErrorZ(LDKCResult_COption_ClosureReasonZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ)); } + operator LDKCResult_COption_ClosureReasonZDecodeErrorZ() && { LDKCResult_COption_ClosureReasonZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ)); return res; } + ~CResult_COption_ClosureReasonZDecodeErrorZ() { CResult_COption_ClosureReasonZDecodeErrorZ_free(self); } + CResult_COption_ClosureReasonZDecodeErrorZ& operator=(CResult_COption_ClosureReasonZDecodeErrorZ&& o) { CResult_COption_ClosureReasonZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_ClosureReasonZDecodeErrorZ)); return *this; } + LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator ->() const { return &self; } +}; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { private: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self; @@ -6643,6 +7653,21 @@ public: const LDKCResult_UpdateFulfillHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFulfillHTLCDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_TxCompleteDecodeErrorZ { +private: + LDKCResult_TxCompleteDecodeErrorZ self; +public: + CResult_TxCompleteDecodeErrorZ(const CResult_TxCompleteDecodeErrorZ&) = delete; + CResult_TxCompleteDecodeErrorZ(CResult_TxCompleteDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCompleteDecodeErrorZ)); } + CResult_TxCompleteDecodeErrorZ(LDKCResult_TxCompleteDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCompleteDecodeErrorZ)); } + operator LDKCResult_TxCompleteDecodeErrorZ() && { LDKCResult_TxCompleteDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCompleteDecodeErrorZ)); return res; } + ~CResult_TxCompleteDecodeErrorZ() { CResult_TxCompleteDecodeErrorZ_free(self); } + CResult_TxCompleteDecodeErrorZ& operator=(CResult_TxCompleteDecodeErrorZ&& o) { CResult_TxCompleteDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCompleteDecodeErrorZ)); return *this; } + LDKCResult_TxCompleteDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxCompleteDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxCompleteDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxCompleteDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NodeFeaturesDecodeErrorZ { private: LDKCResult_NodeFeaturesDecodeErrorZ self; @@ -6673,6 +7698,36 @@ public: const LDKCResult_InMemorySignerDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InMemorySignerDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_TxSignaturesDecodeErrorZ { +private: + LDKCResult_TxSignaturesDecodeErrorZ self; +public: + CResult_TxSignaturesDecodeErrorZ(const CResult_TxSignaturesDecodeErrorZ&) = delete; + CResult_TxSignaturesDecodeErrorZ(CResult_TxSignaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxSignaturesDecodeErrorZ)); } + CResult_TxSignaturesDecodeErrorZ(LDKCResult_TxSignaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxSignaturesDecodeErrorZ)); } + operator LDKCResult_TxSignaturesDecodeErrorZ() && { LDKCResult_TxSignaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxSignaturesDecodeErrorZ)); return res; } + ~CResult_TxSignaturesDecodeErrorZ() { CResult_TxSignaturesDecodeErrorZ_free(self); } + CResult_TxSignaturesDecodeErrorZ& operator=(CResult_TxSignaturesDecodeErrorZ&& o) { CResult_TxSignaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxSignaturesDecodeErrorZ)); return *this; } + LDKCResult_TxSignaturesDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxSignaturesDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxSignaturesDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxSignaturesDecodeErrorZ* operator ->() const { return &self; } +}; +class CVec_HTLCDescriptorZ { +private: + LDKCVec_HTLCDescriptorZ self; +public: + CVec_HTLCDescriptorZ(const CVec_HTLCDescriptorZ&) = delete; + CVec_HTLCDescriptorZ(CVec_HTLCDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCDescriptorZ)); } + CVec_HTLCDescriptorZ(LDKCVec_HTLCDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCDescriptorZ)); } + operator LDKCVec_HTLCDescriptorZ() && { LDKCVec_HTLCDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCDescriptorZ)); return res; } + ~CVec_HTLCDescriptorZ() { CVec_HTLCDescriptorZ_free(self); } + CVec_HTLCDescriptorZ& operator=(CVec_HTLCDescriptorZ&& o) { CVec_HTLCDescriptorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_HTLCDescriptorZ)); return *this; } + LDKCVec_HTLCDescriptorZ* operator &() { return &self; } + LDKCVec_HTLCDescriptorZ* operator ->() { return &self; } + const LDKCVec_HTLCDescriptorZ* operator &() const { return &self; } + const LDKCVec_HTLCDescriptorZ* operator ->() const { return &self; } +}; class CResult_ReplyShortChannelIdsEndDecodeErrorZ { private: LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ self; @@ -6688,21 +7743,6 @@ public: const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* operator ->() const { return &self; } }; -class COption_PathFailureZ { -private: - LDKCOption_PathFailureZ self; -public: - COption_PathFailureZ(const COption_PathFailureZ&) = delete; - COption_PathFailureZ(COption_PathFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PathFailureZ)); } - COption_PathFailureZ(LDKCOption_PathFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PathFailureZ)); } - operator LDKCOption_PathFailureZ() && { LDKCOption_PathFailureZ res = self; memset(&self, 0, sizeof(LDKCOption_PathFailureZ)); return res; } - ~COption_PathFailureZ() { COption_PathFailureZ_free(self); } - COption_PathFailureZ& operator=(COption_PathFailureZ&& o) { COption_PathFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PathFailureZ)); return *this; } - LDKCOption_PathFailureZ* operator &() { return &self; } - LDKCOption_PathFailureZ* operator ->() { return &self; } - const LDKCOption_PathFailureZ* operator &() const { return &self; } - const LDKCOption_PathFailureZ* operator ->() const { return &self; } -}; class COption_ScalarZ { private: LDKCOption_ScalarZ self; @@ -6718,6 +7758,21 @@ public: const LDKCOption_ScalarZ* operator &() const { return &self; } const LDKCOption_ScalarZ* operator ->() const { return &self; } }; +class COption_PathFailureZ { +private: + LDKCOption_PathFailureZ self; +public: + COption_PathFailureZ(const COption_PathFailureZ&) = delete; + COption_PathFailureZ(COption_PathFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PathFailureZ)); } + COption_PathFailureZ(LDKCOption_PathFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PathFailureZ)); } + operator LDKCOption_PathFailureZ() && { LDKCOption_PathFailureZ res = self; memset(&self, 0, sizeof(LDKCOption_PathFailureZ)); return res; } + ~COption_PathFailureZ() { COption_PathFailureZ_free(self); } + COption_PathFailureZ& operator=(COption_PathFailureZ&& o) { COption_PathFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PathFailureZ)); return *this; } + LDKCOption_PathFailureZ* operator &() { return &self; } + LDKCOption_PathFailureZ* operator ->() { return &self; } + const LDKCOption_PathFailureZ* operator &() const { return &self; } + const LDKCOption_PathFailureZ* operator ->() const { return &self; } +}; class CResult_ChannelUpdateInfoDecodeErrorZ { private: LDKCResult_ChannelUpdateInfoDecodeErrorZ self; @@ -6733,21 +7788,6 @@ public: const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_BuiltCommitmentTransactionDecodeErrorZ { -private: - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ self; -public: - CResult_BuiltCommitmentTransactionDecodeErrorZ(const CResult_BuiltCommitmentTransactionDecodeErrorZ&) = delete; - CResult_BuiltCommitmentTransactionDecodeErrorZ(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); } - CResult_BuiltCommitmentTransactionDecodeErrorZ(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); } - operator LDKCResult_BuiltCommitmentTransactionDecodeErrorZ() && { LDKCResult_BuiltCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); return res; } - ~CResult_BuiltCommitmentTransactionDecodeErrorZ() { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); } - CResult_BuiltCommitmentTransactionDecodeErrorZ& operator=(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); return *this; } - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() { return &self; } - LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { private: LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ self; @@ -6763,6 +7803,21 @@ public: const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_UpdateFailHTLCZ { +private: + LDKCVec_UpdateFailHTLCZ self; +public: + CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete; + CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); } + CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); } + operator LDKCVec_UpdateFailHTLCZ() && { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; } + ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); } + CVec_UpdateFailHTLCZ& operator=(CVec_UpdateFailHTLCZ&& o) { CVec_UpdateFailHTLCZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); return *this; } + LDKCVec_UpdateFailHTLCZ* operator &() { return &self; } + LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; } + const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; } + const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; } +}; class CVec_TxOutZ { private: LDKCVec_TxOutZ self; @@ -6778,20 +7833,20 @@ public: const LDKCVec_TxOutZ* operator &() const { return &self; } const LDKCVec_TxOutZ* operator ->() const { return &self; } }; -class CVec_UpdateFailHTLCZ { +class CResult_BuiltCommitmentTransactionDecodeErrorZ { private: - LDKCVec_UpdateFailHTLCZ self; + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ self; public: - CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete; - CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); } - CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); } - operator LDKCVec_UpdateFailHTLCZ() && { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; } - ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); } - CVec_UpdateFailHTLCZ& operator=(CVec_UpdateFailHTLCZ&& o) { CVec_UpdateFailHTLCZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); return *this; } - LDKCVec_UpdateFailHTLCZ* operator &() { return &self; } - LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; } - const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; } - const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; } + CResult_BuiltCommitmentTransactionDecodeErrorZ(const CResult_BuiltCommitmentTransactionDecodeErrorZ&) = delete; + CResult_BuiltCommitmentTransactionDecodeErrorZ(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); } + CResult_BuiltCommitmentTransactionDecodeErrorZ(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); } + operator LDKCResult_BuiltCommitmentTransactionDecodeErrorZ() && { LDKCResult_BuiltCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ)); return res; } + ~CResult_BuiltCommitmentTransactionDecodeErrorZ() { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); } + CResult_BuiltCommitmentTransactionDecodeErrorZ& operator=(CResult_BuiltCommitmentTransactionDecodeErrorZ&& o) { CResult_BuiltCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BuiltCommitmentTransactionDecodeErrorZ)); return *this; } + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() { return &self; } + LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; class CVec_SpendableOutputDescriptorZ { private: @@ -6853,20 +7908,80 @@ public: const LDKCResult_HTLCUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_HTLCUpdateDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_SignatureCVec_SignatureZZ { +class C2Tuple_SignatureCVec_SignatureZZ { +private: + LDKC2Tuple_SignatureCVec_SignatureZZ self; +public: + C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; + C2Tuple_SignatureCVec_SignatureZZ(C2Tuple_SignatureCVec_SignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); } + C2Tuple_SignatureCVec_SignatureZZ(LDKC2Tuple_SignatureCVec_SignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); } + operator LDKC2Tuple_SignatureCVec_SignatureZZ() && { LDKC2Tuple_SignatureCVec_SignatureZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); return res; } + ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } + C2Tuple_SignatureCVec_SignatureZZ& operator=(C2Tuple_SignatureCVec_SignatureZZ&& o) { C2Tuple_SignatureCVec_SignatureZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); return *this; } + LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() { return &self; } + LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() { return &self; } + const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; } + const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; } +}; +class C2Tuple_PartiallySignedTransactionusizeZ { +private: + LDKC2Tuple_PartiallySignedTransactionusizeZ self; +public: + C2Tuple_PartiallySignedTransactionusizeZ(const C2Tuple_PartiallySignedTransactionusizeZ&) = delete; + C2Tuple_PartiallySignedTransactionusizeZ(C2Tuple_PartiallySignedTransactionusizeZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PartiallySignedTransactionusizeZ)); } + C2Tuple_PartiallySignedTransactionusizeZ(LDKC2Tuple_PartiallySignedTransactionusizeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PartiallySignedTransactionusizeZ)); } + operator LDKC2Tuple_PartiallySignedTransactionusizeZ() && { LDKC2Tuple_PartiallySignedTransactionusizeZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PartiallySignedTransactionusizeZ)); return res; } + ~C2Tuple_PartiallySignedTransactionusizeZ() { C2Tuple_PartiallySignedTransactionusizeZ_free(self); } + C2Tuple_PartiallySignedTransactionusizeZ& operator=(C2Tuple_PartiallySignedTransactionusizeZ&& o) { C2Tuple_PartiallySignedTransactionusizeZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PartiallySignedTransactionusizeZ)); return *this; } + LDKC2Tuple_PartiallySignedTransactionusizeZ* operator &() { return &self; } + LDKC2Tuple_PartiallySignedTransactionusizeZ* operator ->() { return &self; } + const LDKC2Tuple_PartiallySignedTransactionusizeZ* operator &() const { return &self; } + const LDKC2Tuple_PartiallySignedTransactionusizeZ* operator ->() const { return &self; } +}; +class CResult_TxAddInputDecodeErrorZ { +private: + LDKCResult_TxAddInputDecodeErrorZ self; +public: + CResult_TxAddInputDecodeErrorZ(const CResult_TxAddInputDecodeErrorZ&) = delete; + CResult_TxAddInputDecodeErrorZ(CResult_TxAddInputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAddInputDecodeErrorZ)); } + CResult_TxAddInputDecodeErrorZ(LDKCResult_TxAddInputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAddInputDecodeErrorZ)); } + operator LDKCResult_TxAddInputDecodeErrorZ() && { LDKCResult_TxAddInputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAddInputDecodeErrorZ)); return res; } + ~CResult_TxAddInputDecodeErrorZ() { CResult_TxAddInputDecodeErrorZ_free(self); } + CResult_TxAddInputDecodeErrorZ& operator=(CResult_TxAddInputDecodeErrorZ&& o) { CResult_TxAddInputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAddInputDecodeErrorZ)); return *this; } + LDKCResult_TxAddInputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxAddInputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxAddInputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxAddInputDecodeErrorZ* operator ->() const { return &self; } +}; +class COption_WriteableScoreZ { +private: + LDKCOption_WriteableScoreZ self; +public: + COption_WriteableScoreZ(const COption_WriteableScoreZ&) = delete; + COption_WriteableScoreZ(COption_WriteableScoreZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_WriteableScoreZ)); } + COption_WriteableScoreZ(LDKCOption_WriteableScoreZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_WriteableScoreZ)); } + operator LDKCOption_WriteableScoreZ() && { LDKCOption_WriteableScoreZ res = self; memset(&self, 0, sizeof(LDKCOption_WriteableScoreZ)); return res; } + ~COption_WriteableScoreZ() { COption_WriteableScoreZ_free(self); } + COption_WriteableScoreZ& operator=(COption_WriteableScoreZ&& o) { COption_WriteableScoreZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_WriteableScoreZ)); return *this; } + LDKCOption_WriteableScoreZ* operator &() { return &self; } + LDKCOption_WriteableScoreZ* operator ->() { return &self; } + const LDKCOption_WriteableScoreZ* operator &() const { return &self; } + const LDKCOption_WriteableScoreZ* operator ->() const { return &self; } +}; +class CResult_TxInitRbfDecodeErrorZ { private: - LDKC2Tuple_SignatureCVec_SignatureZZ self; + LDKCResult_TxInitRbfDecodeErrorZ self; public: - C2Tuple_SignatureCVec_SignatureZZ(const C2Tuple_SignatureCVec_SignatureZZ&) = delete; - C2Tuple_SignatureCVec_SignatureZZ(C2Tuple_SignatureCVec_SignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); } - C2Tuple_SignatureCVec_SignatureZZ(LDKC2Tuple_SignatureCVec_SignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); } - operator LDKC2Tuple_SignatureCVec_SignatureZZ() && { LDKC2Tuple_SignatureCVec_SignatureZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ)); return res; } - ~C2Tuple_SignatureCVec_SignatureZZ() { C2Tuple_SignatureCVec_SignatureZZ_free(self); } - C2Tuple_SignatureCVec_SignatureZZ& operator=(C2Tuple_SignatureCVec_SignatureZZ&& o) { C2Tuple_SignatureCVec_SignatureZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_SignatureCVec_SignatureZZ)); return *this; } - LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() { return &self; } - LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() { return &self; } - const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; } - const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; } + CResult_TxInitRbfDecodeErrorZ(const CResult_TxInitRbfDecodeErrorZ&) = delete; + CResult_TxInitRbfDecodeErrorZ(CResult_TxInitRbfDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxInitRbfDecodeErrorZ)); } + CResult_TxInitRbfDecodeErrorZ(LDKCResult_TxInitRbfDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxInitRbfDecodeErrorZ)); } + operator LDKCResult_TxInitRbfDecodeErrorZ() && { LDKCResult_TxInitRbfDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxInitRbfDecodeErrorZ)); return res; } + ~CResult_TxInitRbfDecodeErrorZ() { CResult_TxInitRbfDecodeErrorZ_free(self); } + CResult_TxInitRbfDecodeErrorZ& operator=(CResult_TxInitRbfDecodeErrorZ&& o) { CResult_TxInitRbfDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxInitRbfDecodeErrorZ)); return *this; } + LDKCResult_TxInitRbfDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxInitRbfDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxInitRbfDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxInitRbfDecodeErrorZ* operator ->() const { return &self; } }; class CVec_OutPointZ { private: @@ -6883,21 +7998,6 @@ public: const LDKCVec_OutPointZ* operator &() const { return &self; } const LDKCVec_OutPointZ* operator ->() const { return &self; } }; -class COption_WriteableScoreZ { -private: - LDKCOption_WriteableScoreZ self; -public: - COption_WriteableScoreZ(const COption_WriteableScoreZ&) = delete; - COption_WriteableScoreZ(COption_WriteableScoreZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_WriteableScoreZ)); } - COption_WriteableScoreZ(LDKCOption_WriteableScoreZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_WriteableScoreZ)); } - operator LDKCOption_WriteableScoreZ() && { LDKCOption_WriteableScoreZ res = self; memset(&self, 0, sizeof(LDKCOption_WriteableScoreZ)); return res; } - ~COption_WriteableScoreZ() { COption_WriteableScoreZ_free(self); } - COption_WriteableScoreZ& operator=(COption_WriteableScoreZ&& o) { COption_WriteableScoreZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_WriteableScoreZ)); return *this; } - LDKCOption_WriteableScoreZ* operator &() { return &self; } - LDKCOption_WriteableScoreZ* operator ->() { return &self; } - const LDKCOption_WriteableScoreZ* operator &() const { return &self; } - const LDKCOption_WriteableScoreZ* operator ->() const { return &self; } -}; class CResult_PositiveTimestampCreationErrorZ { private: LDKCResult_PositiveTimestampCreationErrorZ self; @@ -6928,20 +8028,20 @@ public: const LDKC2Tuple__u168_u168Z* operator &() const { return &self; } const LDKC2Tuple__u168_u168Z* operator ->() const { return &self; } }; -class CResult_InvoiceFeaturesDecodeErrorZ { +class CResult_ChannelMonitorUpdateDecodeErrorZ { private: - LDKCResult_InvoiceFeaturesDecodeErrorZ self; + LDKCResult_ChannelMonitorUpdateDecodeErrorZ self; public: - CResult_InvoiceFeaturesDecodeErrorZ(const CResult_InvoiceFeaturesDecodeErrorZ&) = delete; - CResult_InvoiceFeaturesDecodeErrorZ(CResult_InvoiceFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); } - CResult_InvoiceFeaturesDecodeErrorZ(LDKCResult_InvoiceFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); } - operator LDKCResult_InvoiceFeaturesDecodeErrorZ() && { LDKCResult_InvoiceFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ)); return res; } - ~CResult_InvoiceFeaturesDecodeErrorZ() { CResult_InvoiceFeaturesDecodeErrorZ_free(self); } - CResult_InvoiceFeaturesDecodeErrorZ& operator=(CResult_InvoiceFeaturesDecodeErrorZ&& o) { CResult_InvoiceFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceFeaturesDecodeErrorZ)); return *this; } - LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() { return &self; } - LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } + CResult_ChannelMonitorUpdateDecodeErrorZ(const CResult_ChannelMonitorUpdateDecodeErrorZ&) = delete; + CResult_ChannelMonitorUpdateDecodeErrorZ(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); } + CResult_ChannelMonitorUpdateDecodeErrorZ(LDKCResult_ChannelMonitorUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); } + operator LDKCResult_ChannelMonitorUpdateDecodeErrorZ() && { LDKCResult_ChannelMonitorUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); return res; } + ~CResult_ChannelMonitorUpdateDecodeErrorZ() { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); } + CResult_ChannelMonitorUpdateDecodeErrorZ& operator=(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); return *this; } + LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; } }; class C2Tuple_BlindedPayInfoBlindedPathZ { private: @@ -6958,21 +8058,6 @@ public: const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator &() const { return &self; } const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator ->() const { return &self; } }; -class CResult_ChannelMonitorUpdateDecodeErrorZ { -private: - LDKCResult_ChannelMonitorUpdateDecodeErrorZ self; -public: - CResult_ChannelMonitorUpdateDecodeErrorZ(const CResult_ChannelMonitorUpdateDecodeErrorZ&) = delete; - CResult_ChannelMonitorUpdateDecodeErrorZ(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); } - CResult_ChannelMonitorUpdateDecodeErrorZ(LDKCResult_ChannelMonitorUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); } - operator LDKCResult_ChannelMonitorUpdateDecodeErrorZ() && { LDKCResult_ChannelMonitorUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); return res; } - ~CResult_ChannelMonitorUpdateDecodeErrorZ() { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); } - CResult_ChannelMonitorUpdateDecodeErrorZ& operator=(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); return *this; } - LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_ReplyChannelRangeDecodeErrorZ { private: LDKCResult_ReplyChannelRangeDecodeErrorZ self; @@ -6988,20 +8073,20 @@ public: const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_TrustedClosingTransactionNoneZ { +class COption_PaymentPreimageZ { private: - LDKCResult_TrustedClosingTransactionNoneZ self; + LDKCOption_PaymentPreimageZ self; public: - CResult_TrustedClosingTransactionNoneZ(const CResult_TrustedClosingTransactionNoneZ&) = delete; - CResult_TrustedClosingTransactionNoneZ(CResult_TrustedClosingTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); } - CResult_TrustedClosingTransactionNoneZ(LDKCResult_TrustedClosingTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); } - operator LDKCResult_TrustedClosingTransactionNoneZ() && { LDKCResult_TrustedClosingTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); return res; } - ~CResult_TrustedClosingTransactionNoneZ() { CResult_TrustedClosingTransactionNoneZ_free(self); } - CResult_TrustedClosingTransactionNoneZ& operator=(CResult_TrustedClosingTransactionNoneZ&& o) { CResult_TrustedClosingTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); return *this; } - LDKCResult_TrustedClosingTransactionNoneZ* operator &() { return &self; } - LDKCResult_TrustedClosingTransactionNoneZ* operator ->() { return &self; } - const LDKCResult_TrustedClosingTransactionNoneZ* operator &() const { return &self; } - const LDKCResult_TrustedClosingTransactionNoneZ* operator ->() const { return &self; } + COption_PaymentPreimageZ(const COption_PaymentPreimageZ&) = delete; + COption_PaymentPreimageZ(COption_PaymentPreimageZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentPreimageZ)); } + COption_PaymentPreimageZ(LDKCOption_PaymentPreimageZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentPreimageZ)); } + operator LDKCOption_PaymentPreimageZ() && { LDKCOption_PaymentPreimageZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentPreimageZ)); return res; } + ~COption_PaymentPreimageZ() { COption_PaymentPreimageZ_free(self); } + COption_PaymentPreimageZ& operator=(COption_PaymentPreimageZ&& o) { COption_PaymentPreimageZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentPreimageZ)); return *this; } + LDKCOption_PaymentPreimageZ* operator &() { return &self; } + LDKCOption_PaymentPreimageZ* operator ->() { return &self; } + const LDKCOption_PaymentPreimageZ* operator &() const { return &self; } + const LDKCOption_PaymentPreimageZ* operator ->() const { return &self; } }; class CResult_NetAddressDecodeErrorZ { private: @@ -7018,6 +8103,21 @@ public: const LDKCResult_NetAddressDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NetAddressDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_UnsignedNodeAnnouncementDecodeErrorZ { +private: + LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self; +public: + CResult_UnsignedNodeAnnouncementDecodeErrorZ(const CResult_UnsignedNodeAnnouncementDecodeErrorZ&) = delete; + CResult_UnsignedNodeAnnouncementDecodeErrorZ(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); } + CResult_UnsignedNodeAnnouncementDecodeErrorZ(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); } + operator LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); return res; } + ~CResult_UnsignedNodeAnnouncementDecodeErrorZ() { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); } + CResult_UnsignedNodeAnnouncementDecodeErrorZ& operator=(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); return *this; } + LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() { return &self; } + LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_PublicKeyTypeZ { private: LDKC2Tuple_PublicKeyTypeZ self; @@ -7033,6 +8133,21 @@ public: const LDKC2Tuple_PublicKeyTypeZ* operator &() const { return &self; } const LDKC2Tuple_PublicKeyTypeZ* operator ->() const { return &self; } }; +class CResult_TxRemoveOutputDecodeErrorZ { +private: + LDKCResult_TxRemoveOutputDecodeErrorZ self; +public: + CResult_TxRemoveOutputDecodeErrorZ(const CResult_TxRemoveOutputDecodeErrorZ&) = delete; + CResult_TxRemoveOutputDecodeErrorZ(CResult_TxRemoveOutputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxRemoveOutputDecodeErrorZ)); } + CResult_TxRemoveOutputDecodeErrorZ(LDKCResult_TxRemoveOutputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ)); } + operator LDKCResult_TxRemoveOutputDecodeErrorZ() && { LDKCResult_TxRemoveOutputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ)); return res; } + ~CResult_TxRemoveOutputDecodeErrorZ() { CResult_TxRemoveOutputDecodeErrorZ_free(self); } + CResult_TxRemoveOutputDecodeErrorZ& operator=(CResult_TxRemoveOutputDecodeErrorZ&& o) { CResult_TxRemoveOutputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxRemoveOutputDecodeErrorZ)); return *this; } + LDKCResult_TxRemoveOutputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxRemoveOutputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxRemoveOutputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxRemoveOutputDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ChannelReestablishDecodeErrorZ { private: LDKCResult_ChannelReestablishDecodeErrorZ self; @@ -7048,6 +8163,21 @@ public: const LDKCResult_ChannelReestablishDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ScriptNoneZ { +private: + LDKCResult_ScriptNoneZ self; +public: + CResult_ScriptNoneZ(const CResult_ScriptNoneZ&) = delete; + CResult_ScriptNoneZ(CResult_ScriptNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ScriptNoneZ)); } + CResult_ScriptNoneZ(LDKCResult_ScriptNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ScriptNoneZ)); } + operator LDKCResult_ScriptNoneZ() && { LDKCResult_ScriptNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_ScriptNoneZ)); return res; } + ~CResult_ScriptNoneZ() { CResult_ScriptNoneZ_free(self); } + CResult_ScriptNoneZ& operator=(CResult_ScriptNoneZ&& o) { CResult_ScriptNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ScriptNoneZ)); return *this; } + LDKCResult_ScriptNoneZ* operator &() { return &self; } + LDKCResult_ScriptNoneZ* operator ->() { return &self; } + const LDKCResult_ScriptNoneZ* operator &() const { return &self; } + const LDKCResult_ScriptNoneZ* operator ->() const { return &self; } +}; class CResult_OnionMessageDecodeErrorZ { private: LDKCResult_OnionMessageDecodeErrorZ self; @@ -7063,35 +8193,35 @@ public: const LDKCResult_OnionMessageDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OnionMessageDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_UnsignedNodeAnnouncementDecodeErrorZ { +class CResult_TrustedClosingTransactionNoneZ { private: - LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self; + LDKCResult_TrustedClosingTransactionNoneZ self; public: - CResult_UnsignedNodeAnnouncementDecodeErrorZ(const CResult_UnsignedNodeAnnouncementDecodeErrorZ&) = delete; - CResult_UnsignedNodeAnnouncementDecodeErrorZ(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); } - CResult_UnsignedNodeAnnouncementDecodeErrorZ(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); } - operator LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ() && { LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ)); return res; } - ~CResult_UnsignedNodeAnnouncementDecodeErrorZ() { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); } - CResult_UnsignedNodeAnnouncementDecodeErrorZ& operator=(CResult_UnsignedNodeAnnouncementDecodeErrorZ&& o) { CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedNodeAnnouncementDecodeErrorZ)); return *this; } - LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() { return &self; } - LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } + CResult_TrustedClosingTransactionNoneZ(const CResult_TrustedClosingTransactionNoneZ&) = delete; + CResult_TrustedClosingTransactionNoneZ(CResult_TrustedClosingTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); } + CResult_TrustedClosingTransactionNoneZ(LDKCResult_TrustedClosingTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); } + operator LDKCResult_TrustedClosingTransactionNoneZ() && { LDKCResult_TrustedClosingTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); return res; } + ~CResult_TrustedClosingTransactionNoneZ() { CResult_TrustedClosingTransactionNoneZ_free(self); } + CResult_TrustedClosingTransactionNoneZ& operator=(CResult_TrustedClosingTransactionNoneZ&& o) { CResult_TrustedClosingTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); return *this; } + LDKCResult_TrustedClosingTransactionNoneZ* operator &() { return &self; } + LDKCResult_TrustedClosingTransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TrustedClosingTransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TrustedClosingTransactionNoneZ* operator ->() const { return &self; } }; -class CResult_InvoiceSignOrCreationErrorZ { +class CResult_Bolt11InvoiceParseOrSemanticErrorZ { private: - LDKCResult_InvoiceSignOrCreationErrorZ self; + LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ self; public: - CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete; - CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); } - CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); } - operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; } - ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); } - CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } + CResult_Bolt11InvoiceParseOrSemanticErrorZ(const CResult_Bolt11InvoiceParseOrSemanticErrorZ&) = delete; + CResult_Bolt11InvoiceParseOrSemanticErrorZ(CResult_Bolt11InvoiceParseOrSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt11InvoiceParseOrSemanticErrorZ)); } + CResult_Bolt11InvoiceParseOrSemanticErrorZ(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ)); } + operator LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ() && { LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ)); return res; } + ~CResult_Bolt11InvoiceParseOrSemanticErrorZ() { CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(self); } + CResult_Bolt11InvoiceParseOrSemanticErrorZ& operator=(CResult_Bolt11InvoiceParseOrSemanticErrorZ&& o) { CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt11InvoiceParseOrSemanticErrorZ)); return *this; } + LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator &() { return &self; } + LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator ->() const { return &self; } }; class CResult_InitFeaturesDecodeErrorZ { private: @@ -7153,6 +8283,21 @@ public: const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class COption_PackedLockTimeZ { +private: + LDKCOption_PackedLockTimeZ self; +public: + COption_PackedLockTimeZ(const COption_PackedLockTimeZ&) = delete; + COption_PackedLockTimeZ(COption_PackedLockTimeZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PackedLockTimeZ)); } + COption_PackedLockTimeZ(LDKCOption_PackedLockTimeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PackedLockTimeZ)); } + operator LDKCOption_PackedLockTimeZ() && { LDKCOption_PackedLockTimeZ res = self; memset(&self, 0, sizeof(LDKCOption_PackedLockTimeZ)); return res; } + ~COption_PackedLockTimeZ() { COption_PackedLockTimeZ_free(self); } + COption_PackedLockTimeZ& operator=(COption_PackedLockTimeZ&& o) { COption_PackedLockTimeZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PackedLockTimeZ)); return *this; } + LDKCOption_PackedLockTimeZ* operator &() { return &self; } + LDKCOption_PackedLockTimeZ* operator ->() { return &self; } + const LDKCOption_PackedLockTimeZ* operator &() const { return &self; } + const LDKCOption_PackedLockTimeZ* operator ->() const { return &self; } +}; class CVec_TransactionOutputsZ { private: LDKCVec_TransactionOutputsZ self; @@ -7213,6 +8358,21 @@ public: const LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ProbabilisticScorerDecodeErrorZ { +private: + LDKCResult_ProbabilisticScorerDecodeErrorZ self; +public: + CResult_ProbabilisticScorerDecodeErrorZ(const CResult_ProbabilisticScorerDecodeErrorZ&) = delete; + CResult_ProbabilisticScorerDecodeErrorZ(CResult_ProbabilisticScorerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); } + CResult_ProbabilisticScorerDecodeErrorZ(LDKCResult_ProbabilisticScorerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); } + operator LDKCResult_ProbabilisticScorerDecodeErrorZ() && { LDKCResult_ProbabilisticScorerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); return res; } + ~CResult_ProbabilisticScorerDecodeErrorZ() { CResult_ProbabilisticScorerDecodeErrorZ_free(self); } + CResult_ProbabilisticScorerDecodeErrorZ& operator=(CResult_ProbabilisticScorerDecodeErrorZ&& o) { CResult_ProbabilisticScorerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); return *this; } + LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() { return &self; } + LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ShutdownScriptDecodeErrorZ { private: LDKCResult_ShutdownScriptDecodeErrorZ self; @@ -7228,20 +8388,20 @@ public: const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ProbabilisticScorerDecodeErrorZ { +class CResult_SiPrefixBolt11ParseErrorZ { private: - LDKCResult_ProbabilisticScorerDecodeErrorZ self; + LDKCResult_SiPrefixBolt11ParseErrorZ self; public: - CResult_ProbabilisticScorerDecodeErrorZ(const CResult_ProbabilisticScorerDecodeErrorZ&) = delete; - CResult_ProbabilisticScorerDecodeErrorZ(CResult_ProbabilisticScorerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); } - CResult_ProbabilisticScorerDecodeErrorZ(LDKCResult_ProbabilisticScorerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); } - operator LDKCResult_ProbabilisticScorerDecodeErrorZ() && { LDKCResult_ProbabilisticScorerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ)); return res; } - ~CResult_ProbabilisticScorerDecodeErrorZ() { CResult_ProbabilisticScorerDecodeErrorZ_free(self); } - CResult_ProbabilisticScorerDecodeErrorZ& operator=(CResult_ProbabilisticScorerDecodeErrorZ&& o) { CResult_ProbabilisticScorerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ProbabilisticScorerDecodeErrorZ)); return *this; } - LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() { return &self; } - LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() const { return &self; } + CResult_SiPrefixBolt11ParseErrorZ(const CResult_SiPrefixBolt11ParseErrorZ&) = delete; + CResult_SiPrefixBolt11ParseErrorZ(CResult_SiPrefixBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); } + CResult_SiPrefixBolt11ParseErrorZ(LDKCResult_SiPrefixBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); } + operator LDKCResult_SiPrefixBolt11ParseErrorZ() && { LDKCResult_SiPrefixBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); return res; } + ~CResult_SiPrefixBolt11ParseErrorZ() { CResult_SiPrefixBolt11ParseErrorZ_free(self); } + CResult_SiPrefixBolt11ParseErrorZ& operator=(CResult_SiPrefixBolt11ParseErrorZ&& o) { CResult_SiPrefixBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); return *this; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() { return &self; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() const { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() const { return &self; } }; class C2Tuple_usizeTransactionZ { private: @@ -7258,21 +8418,6 @@ public: const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; } const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; } }; -class CResult_TxCreationKeysDecodeErrorZ { -private: - LDKCResult_TxCreationKeysDecodeErrorZ self; -public: - CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; - CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } - CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } - operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } - ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } - CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_NodeAnnouncementDecodeErrorZ { private: LDKCResult_NodeAnnouncementDecodeErrorZ self; @@ -7288,6 +8433,21 @@ public: const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_FutureZ { +private: + LDKCVec_FutureZ self; +public: + CVec_FutureZ(const CVec_FutureZ&) = delete; + CVec_FutureZ(CVec_FutureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_FutureZ)); } + CVec_FutureZ(LDKCVec_FutureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_FutureZ)); } + operator LDKCVec_FutureZ() && { LDKCVec_FutureZ res = self; memset(&self, 0, sizeof(LDKCVec_FutureZ)); return res; } + ~CVec_FutureZ() { CVec_FutureZ_free(self); } + CVec_FutureZ& operator=(CVec_FutureZ&& o) { CVec_FutureZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_FutureZ)); return *this; } + LDKCVec_FutureZ* operator &() { return &self; } + LDKCVec_FutureZ* operator ->() { return &self; } + const LDKCVec_FutureZ* operator &() const { return &self; } + const LDKCVec_FutureZ* operator ->() const { return &self; } +}; class CVec_ChannelMonitorZ { private: LDKCVec_ChannelMonitorZ self; @@ -7303,35 +8463,35 @@ public: const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } }; -class CResult_BlindedPathDecodeErrorZ { +class CResult_AcceptChannelV2DecodeErrorZ { private: - LDKCResult_BlindedPathDecodeErrorZ self; + LDKCResult_AcceptChannelV2DecodeErrorZ self; public: - CResult_BlindedPathDecodeErrorZ(const CResult_BlindedPathDecodeErrorZ&) = delete; - CResult_BlindedPathDecodeErrorZ(CResult_BlindedPathDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); } - CResult_BlindedPathDecodeErrorZ(LDKCResult_BlindedPathDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); } - operator LDKCResult_BlindedPathDecodeErrorZ() && { LDKCResult_BlindedPathDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); return res; } - ~CResult_BlindedPathDecodeErrorZ() { CResult_BlindedPathDecodeErrorZ_free(self); } - CResult_BlindedPathDecodeErrorZ& operator=(CResult_BlindedPathDecodeErrorZ&& o) { CResult_BlindedPathDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); return *this; } - LDKCResult_BlindedPathDecodeErrorZ* operator &() { return &self; } - LDKCResult_BlindedPathDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_BlindedPathDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_BlindedPathDecodeErrorZ* operator ->() const { return &self; } + CResult_AcceptChannelV2DecodeErrorZ(const CResult_AcceptChannelV2DecodeErrorZ&) = delete; + CResult_AcceptChannelV2DecodeErrorZ(CResult_AcceptChannelV2DecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AcceptChannelV2DecodeErrorZ)); } + CResult_AcceptChannelV2DecodeErrorZ(LDKCResult_AcceptChannelV2DecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ)); } + operator LDKCResult_AcceptChannelV2DecodeErrorZ() && { LDKCResult_AcceptChannelV2DecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ)); return res; } + ~CResult_AcceptChannelV2DecodeErrorZ() { CResult_AcceptChannelV2DecodeErrorZ_free(self); } + CResult_AcceptChannelV2DecodeErrorZ& operator=(CResult_AcceptChannelV2DecodeErrorZ&& o) { CResult_AcceptChannelV2DecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AcceptChannelV2DecodeErrorZ)); return *this; } + LDKCResult_AcceptChannelV2DecodeErrorZ* operator &() { return &self; } + LDKCResult_AcceptChannelV2DecodeErrorZ* operator ->() { return &self; } + const LDKCResult_AcceptChannelV2DecodeErrorZ* operator &() const { return &self; } + const LDKCResult_AcceptChannelV2DecodeErrorZ* operator ->() const { return &self; } }; -class CVec_FutureZ { +class CResult_TxCreationKeysDecodeErrorZ { private: - LDKCVec_FutureZ self; + LDKCResult_TxCreationKeysDecodeErrorZ self; public: - CVec_FutureZ(const CVec_FutureZ&) = delete; - CVec_FutureZ(CVec_FutureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_FutureZ)); } - CVec_FutureZ(LDKCVec_FutureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_FutureZ)); } - operator LDKCVec_FutureZ() && { LDKCVec_FutureZ res = self; memset(&self, 0, sizeof(LDKCVec_FutureZ)); return res; } - ~CVec_FutureZ() { CVec_FutureZ_free(self); } - CVec_FutureZ& operator=(CVec_FutureZ&& o) { CVec_FutureZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_FutureZ)); return *this; } - LDKCVec_FutureZ* operator &() { return &self; } - LDKCVec_FutureZ* operator ->() { return &self; } - const LDKCVec_FutureZ* operator &() const { return &self; } - const LDKCVec_FutureZ* operator ->() const { return &self; } + CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; + CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } + CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } + operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } + ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } + CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } }; class CResult_RouteHopDecodeErrorZ { private: @@ -7348,6 +8508,51 @@ public: const LDKCResult_RouteHopDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteHopDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_HTLCOutputInCommitmentZ { +private: + LDKCVec_HTLCOutputInCommitmentZ self; +public: + CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete; + CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); } + CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); } + operator LDKCVec_HTLCOutputInCommitmentZ() && { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; } + ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); } + CVec_HTLCOutputInCommitmentZ& operator=(CVec_HTLCOutputInCommitmentZ&& o) { CVec_HTLCOutputInCommitmentZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); return *this; } + LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; } + LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; } + const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; } + const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; } +}; +class CResult_CoinSelectionNoneZ { +private: + LDKCResult_CoinSelectionNoneZ self; +public: + CResult_CoinSelectionNoneZ(const CResult_CoinSelectionNoneZ&) = delete; + CResult_CoinSelectionNoneZ(CResult_CoinSelectionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CoinSelectionNoneZ)); } + CResult_CoinSelectionNoneZ(LDKCResult_CoinSelectionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CoinSelectionNoneZ)); } + operator LDKCResult_CoinSelectionNoneZ() && { LDKCResult_CoinSelectionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CoinSelectionNoneZ)); return res; } + ~CResult_CoinSelectionNoneZ() { CResult_CoinSelectionNoneZ_free(self); } + CResult_CoinSelectionNoneZ& operator=(CResult_CoinSelectionNoneZ&& o) { CResult_CoinSelectionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CoinSelectionNoneZ)); return *this; } + LDKCResult_CoinSelectionNoneZ* operator &() { return &self; } + LDKCResult_CoinSelectionNoneZ* operator ->() { return &self; } + const LDKCResult_CoinSelectionNoneZ* operator &() const { return &self; } + const LDKCResult_CoinSelectionNoneZ* operator ->() const { return &self; } +}; +class CResult_BlindedPathDecodeErrorZ { +private: + LDKCResult_BlindedPathDecodeErrorZ self; +public: + CResult_BlindedPathDecodeErrorZ(const CResult_BlindedPathDecodeErrorZ&) = delete; + CResult_BlindedPathDecodeErrorZ(CResult_BlindedPathDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); } + CResult_BlindedPathDecodeErrorZ(LDKCResult_BlindedPathDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); } + operator LDKCResult_BlindedPathDecodeErrorZ() && { LDKCResult_BlindedPathDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); return res; } + ~CResult_BlindedPathDecodeErrorZ() { CResult_BlindedPathDecodeErrorZ_free(self); } + CResult_BlindedPathDecodeErrorZ& operator=(CResult_BlindedPathDecodeErrorZ&& o) { CResult_BlindedPathDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); return *this; } + LDKCResult_BlindedPathDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedPathDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedPathDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedPathDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_BalanceZ { private: LDKCVec_BalanceZ self; @@ -7363,6 +8568,21 @@ public: const LDKCVec_BalanceZ* operator &() const { return &self; } const LDKCVec_BalanceZ* operator ->() const { return &self; } }; +class CResult_MaxDustHTLCExposureDecodeErrorZ { +private: + LDKCResult_MaxDustHTLCExposureDecodeErrorZ self; +public: + CResult_MaxDustHTLCExposureDecodeErrorZ(const CResult_MaxDustHTLCExposureDecodeErrorZ&) = delete; + CResult_MaxDustHTLCExposureDecodeErrorZ(CResult_MaxDustHTLCExposureDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_MaxDustHTLCExposureDecodeErrorZ)); } + CResult_MaxDustHTLCExposureDecodeErrorZ(LDKCResult_MaxDustHTLCExposureDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ)); } + operator LDKCResult_MaxDustHTLCExposureDecodeErrorZ() && { LDKCResult_MaxDustHTLCExposureDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ)); return res; } + ~CResult_MaxDustHTLCExposureDecodeErrorZ() { CResult_MaxDustHTLCExposureDecodeErrorZ_free(self); } + CResult_MaxDustHTLCExposureDecodeErrorZ& operator=(CResult_MaxDustHTLCExposureDecodeErrorZ&& o) { CResult_MaxDustHTLCExposureDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_MaxDustHTLCExposureDecodeErrorZ)); return *this; } + LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator &() { return &self; } + LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_FundingSignedDecodeErrorZ { private: LDKCResult_FundingSignedDecodeErrorZ self; @@ -7408,21 +8628,6 @@ public: const LDKC2Tuple_Z* operator &() const { return &self; } const LDKC2Tuple_Z* operator ->() const { return &self; } }; -class C3Tuple_RawInvoice_u832InvoiceSignatureZ { -private: - LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ self; -public: - C3Tuple_RawInvoice_u832InvoiceSignatureZ(const C3Tuple_RawInvoice_u832InvoiceSignatureZ&) = delete; - C3Tuple_RawInvoice_u832InvoiceSignatureZ(C3Tuple_RawInvoice_u832InvoiceSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_RawInvoice_u832InvoiceSignatureZ)); } - C3Tuple_RawInvoice_u832InvoiceSignatureZ(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ)); } - operator LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ() && { LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ)); return res; } - ~C3Tuple_RawInvoice_u832InvoiceSignatureZ() { C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(self); } - C3Tuple_RawInvoice_u832InvoiceSignatureZ& operator=(C3Tuple_RawInvoice_u832InvoiceSignatureZ&& o) { C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_RawInvoice_u832InvoiceSignatureZ)); return *this; } - LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator &() { return &self; } - LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator ->() { return &self; } - const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator &() const { return &self; } - const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator ->() const { return &self; } -}; class CVec_PathZ { private: LDKCVec_PathZ self; @@ -7492,26 +8697,11 @@ public: CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } operator LDKCVec_u8Z() && { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } ~CVec_u8Z() { CVec_u8Z_free(self); } - CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } - LDKCVec_u8Z* operator &() { return &self; } - LDKCVec_u8Z* operator ->() { return &self; } - const LDKCVec_u8Z* operator &() const { return &self; } - const LDKCVec_u8Z* operator ->() const { return &self; } -}; -class CResult_ChannelPublicKeysDecodeErrorZ { -private: - LDKCResult_ChannelPublicKeysDecodeErrorZ self; -public: - CResult_ChannelPublicKeysDecodeErrorZ(const CResult_ChannelPublicKeysDecodeErrorZ&) = delete; - CResult_ChannelPublicKeysDecodeErrorZ(CResult_ChannelPublicKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelPublicKeysDecodeErrorZ)); } - CResult_ChannelPublicKeysDecodeErrorZ(LDKCResult_ChannelPublicKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ)); } - operator LDKCResult_ChannelPublicKeysDecodeErrorZ() && { LDKCResult_ChannelPublicKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ)); return res; } - ~CResult_ChannelPublicKeysDecodeErrorZ() { CResult_ChannelPublicKeysDecodeErrorZ_free(self); } - CResult_ChannelPublicKeysDecodeErrorZ& operator=(CResult_ChannelPublicKeysDecodeErrorZ&& o) { CResult_ChannelPublicKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelPublicKeysDecodeErrorZ)); return *this; } - LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; } + CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } + LDKCVec_u8Z* operator &() { return &self; } + LDKCVec_u8Z* operator ->() { return &self; } + const LDKCVec_u8Z* operator &() const { return &self; } + const LDKCVec_u8Z* operator ->() const { return &self; } }; class CResult_RouteLightningErrorZ { private: @@ -7543,6 +8733,36 @@ public: const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; } const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; } }; +class CResult_ChannelPublicKeysDecodeErrorZ { +private: + LDKCResult_ChannelPublicKeysDecodeErrorZ self; +public: + CResult_ChannelPublicKeysDecodeErrorZ(const CResult_ChannelPublicKeysDecodeErrorZ&) = delete; + CResult_ChannelPublicKeysDecodeErrorZ(CResult_ChannelPublicKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelPublicKeysDecodeErrorZ)); } + CResult_ChannelPublicKeysDecodeErrorZ(LDKCResult_ChannelPublicKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ)); } + operator LDKCResult_ChannelPublicKeysDecodeErrorZ() && { LDKCResult_ChannelPublicKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ)); return res; } + ~CResult_ChannelPublicKeysDecodeErrorZ() { CResult_ChannelPublicKeysDecodeErrorZ_free(self); } + CResult_ChannelPublicKeysDecodeErrorZ& operator=(CResult_ChannelPublicKeysDecodeErrorZ&& o) { CResult_ChannelPublicKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelPublicKeysDecodeErrorZ)); return *this; } + LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; } +}; +class CVec_C2Tuple_TxidCOption_BlockHashZZZ { +private: + LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ self; +public: + CVec_C2Tuple_TxidCOption_BlockHashZZZ(const CVec_C2Tuple_TxidCOption_BlockHashZZZ&) = delete; + CVec_C2Tuple_TxidCOption_BlockHashZZZ(CVec_C2Tuple_TxidCOption_BlockHashZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_TxidCOption_BlockHashZZZ)); } + CVec_C2Tuple_TxidCOption_BlockHashZZZ(LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ)); } + operator LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ() && { LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ)); return res; } + ~CVec_C2Tuple_TxidCOption_BlockHashZZZ() { CVec_C2Tuple_TxidCOption_BlockHashZZZ_free(self); } + CVec_C2Tuple_TxidCOption_BlockHashZZZ& operator=(CVec_C2Tuple_TxidCOption_BlockHashZZZ&& o) { CVec_C2Tuple_TxidCOption_BlockHashZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_TxidCOption_BlockHashZZZ)); return *this; } + LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ* operator &() { return &self; } + LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_TxidCOption_BlockHashZZZ* operator ->() const { return &self; } +}; class CResult_HolderCommitmentTransactionDecodeErrorZ { private: LDKCResult_HolderCommitmentTransactionDecodeErrorZ self; @@ -7693,6 +8913,21 @@ public: const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; +class CResult_Bolt11InvoiceFeaturesDecodeErrorZ { +private: + LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ self; +public: + CResult_Bolt11InvoiceFeaturesDecodeErrorZ(const CResult_Bolt11InvoiceFeaturesDecodeErrorZ&) = delete; + CResult_Bolt11InvoiceFeaturesDecodeErrorZ(CResult_Bolt11InvoiceFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt11InvoiceFeaturesDecodeErrorZ)); } + CResult_Bolt11InvoiceFeaturesDecodeErrorZ(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ)); } + operator LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ() && { LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ)); return res; } + ~CResult_Bolt11InvoiceFeaturesDecodeErrorZ() { CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(self); } + CResult_Bolt11InvoiceFeaturesDecodeErrorZ& operator=(CResult_Bolt11InvoiceFeaturesDecodeErrorZ&& o) { CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt11InvoiceFeaturesDecodeErrorZ)); return *this; } + LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_MessageSendEventZ { private: LDKCVec_MessageSendEventZ self; @@ -7783,6 +9018,36 @@ public: const LDKCResult_BlindedPayInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedPayInfoDecodeErrorZ* operator ->() const { return &self; } }; +class COption_ChannelShutdownStateZ { +private: + LDKCOption_ChannelShutdownStateZ self; +public: + COption_ChannelShutdownStateZ(const COption_ChannelShutdownStateZ&) = delete; + COption_ChannelShutdownStateZ(COption_ChannelShutdownStateZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ChannelShutdownStateZ)); } + COption_ChannelShutdownStateZ(LDKCOption_ChannelShutdownStateZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ChannelShutdownStateZ)); } + operator LDKCOption_ChannelShutdownStateZ() && { LDKCOption_ChannelShutdownStateZ res = self; memset(&self, 0, sizeof(LDKCOption_ChannelShutdownStateZ)); return res; } + ~COption_ChannelShutdownStateZ() { COption_ChannelShutdownStateZ_free(self); } + COption_ChannelShutdownStateZ& operator=(COption_ChannelShutdownStateZ&& o) { COption_ChannelShutdownStateZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ChannelShutdownStateZ)); return *this; } + LDKCOption_ChannelShutdownStateZ* operator &() { return &self; } + LDKCOption_ChannelShutdownStateZ* operator ->() { return &self; } + const LDKCOption_ChannelShutdownStateZ* operator &() const { return &self; } + const LDKCOption_ChannelShutdownStateZ* operator ->() const { return &self; } +}; +class CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { +private: + LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ self; +public: + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ(const CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ&) = delete; + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ(CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ)); } + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ(LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ)); } + operator LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ() && { LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ)); return res; } + ~CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ() { CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_free(self); } + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ& operator=(CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ&& o) { CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ)); return *this; } + LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ* operator &() { return &self; } + LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ* operator ->() const { return &self; } +}; class CResult_SharedSecretNoneZ { private: LDKCResult_SharedSecretNoneZ self; @@ -7858,6 +9123,21 @@ public: const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_HostnameDecodeErrorZ { +private: + LDKCResult_HostnameDecodeErrorZ self; +public: + CResult_HostnameDecodeErrorZ(const CResult_HostnameDecodeErrorZ&) = delete; + CResult_HostnameDecodeErrorZ(CResult_HostnameDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HostnameDecodeErrorZ)); } + CResult_HostnameDecodeErrorZ(LDKCResult_HostnameDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HostnameDecodeErrorZ)); } + operator LDKCResult_HostnameDecodeErrorZ() && { LDKCResult_HostnameDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HostnameDecodeErrorZ)); return res; } + ~CResult_HostnameDecodeErrorZ() { CResult_HostnameDecodeErrorZ_free(self); } + CResult_HostnameDecodeErrorZ& operator=(CResult_HostnameDecodeErrorZ&& o) { CResult_HostnameDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HostnameDecodeErrorZ)); return *this; } + LDKCResult_HostnameDecodeErrorZ* operator &() { return &self; } + LDKCResult_HostnameDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HostnameDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HostnameDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_SignatureZ { private: LDKCVec_SignatureZ self; @@ -7963,6 +9243,21 @@ public: const LDKCResult_ChannelTypeFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelTypeFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class COption_TxidZ { +private: + LDKCOption_TxidZ self; +public: + COption_TxidZ(const COption_TxidZ&) = delete; + COption_TxidZ(COption_TxidZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_TxidZ)); } + COption_TxidZ(LDKCOption_TxidZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_TxidZ)); } + operator LDKCOption_TxidZ() && { LDKCOption_TxidZ res = self; memset(&self, 0, sizeof(LDKCOption_TxidZ)); return res; } + ~COption_TxidZ() { COption_TxidZ_free(self); } + COption_TxidZ& operator=(COption_TxidZ&& o) { COption_TxidZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_TxidZ)); return *this; } + LDKCOption_TxidZ* operator &() { return &self; } + LDKCOption_TxidZ* operator ->() { return &self; } + const LDKCOption_TxidZ* operator &() const { return &self; } + const LDKCOption_TxidZ* operator ->() const { return &self; } +}; class CVec_RouteHintZ { private: LDKCVec_RouteHintZ self; @@ -7978,21 +9273,6 @@ public: const LDKCVec_RouteHintZ* operator &() const { return &self; } const LDKCVec_RouteHintZ* operator ->() const { return &self; } }; -class COption_PaymentFailureReasonZ { -private: - LDKCOption_PaymentFailureReasonZ self; -public: - COption_PaymentFailureReasonZ(const COption_PaymentFailureReasonZ&) = delete; - COption_PaymentFailureReasonZ(COption_PaymentFailureReasonZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); } - COption_PaymentFailureReasonZ(LDKCOption_PaymentFailureReasonZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); } - operator LDKCOption_PaymentFailureReasonZ() && { LDKCOption_PaymentFailureReasonZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); return res; } - ~COption_PaymentFailureReasonZ() { COption_PaymentFailureReasonZ_free(self); } - COption_PaymentFailureReasonZ& operator=(COption_PaymentFailureReasonZ&& o) { COption_PaymentFailureReasonZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); return *this; } - LDKCOption_PaymentFailureReasonZ* operator &() { return &self; } - LDKCOption_PaymentFailureReasonZ* operator ->() { return &self; } - const LDKCOption_PaymentFailureReasonZ* operator &() const { return &self; } - const LDKCOption_PaymentFailureReasonZ* operator ->() const { return &self; } -}; class COption_u16Z { private: LDKCOption_u16Z self; @@ -8008,6 +9288,21 @@ public: const LDKCOption_u16Z* operator &() const { return &self; } const LDKCOption_u16Z* operator ->() const { return &self; } }; +class COption_PaymentFailureReasonZ { +private: + LDKCOption_PaymentFailureReasonZ self; +public: + COption_PaymentFailureReasonZ(const COption_PaymentFailureReasonZ&) = delete; + COption_PaymentFailureReasonZ(COption_PaymentFailureReasonZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); } + COption_PaymentFailureReasonZ(LDKCOption_PaymentFailureReasonZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); } + operator LDKCOption_PaymentFailureReasonZ() && { LDKCOption_PaymentFailureReasonZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); return res; } + ~COption_PaymentFailureReasonZ() { COption_PaymentFailureReasonZ_free(self); } + COption_PaymentFailureReasonZ& operator=(COption_PaymentFailureReasonZ&& o) { COption_PaymentFailureReasonZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); return *this; } + LDKCOption_PaymentFailureReasonZ* operator &() { return &self; } + LDKCOption_PaymentFailureReasonZ* operator ->() { return &self; } + const LDKCOption_PaymentFailureReasonZ* operator &() const { return &self; } + const LDKCOption_PaymentFailureReasonZ* operator ->() const { return &self; } +}; class CVec_ChainHashZ { private: LDKCVec_ChainHashZ self; @@ -8023,6 +9318,21 @@ public: const LDKCVec_ChainHashZ* operator &() const { return &self; } const LDKCVec_ChainHashZ* operator ->() const { return &self; } }; +class CVec_WitnessZ { +private: + LDKCVec_WitnessZ self; +public: + CVec_WitnessZ(const CVec_WitnessZ&) = delete; + CVec_WitnessZ(CVec_WitnessZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_WitnessZ)); } + CVec_WitnessZ(LDKCVec_WitnessZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_WitnessZ)); } + operator LDKCVec_WitnessZ() && { LDKCVec_WitnessZ res = self; memset(&self, 0, sizeof(LDKCVec_WitnessZ)); return res; } + ~CVec_WitnessZ() { CVec_WitnessZ_free(self); } + CVec_WitnessZ& operator=(CVec_WitnessZ&& o) { CVec_WitnessZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_WitnessZ)); return *this; } + LDKCVec_WitnessZ* operator &() { return &self; } + LDKCVec_WitnessZ* operator ->() { return &self; } + const LDKCVec_WitnessZ* operator &() const { return &self; } + const LDKCVec_WitnessZ* operator ->() const { return &self; } +}; class CResult_BlindedTailDecodeErrorZ { private: LDKCResult_BlindedTailDecodeErrorZ self; @@ -8038,6 +9348,21 @@ public: const LDKCResult_BlindedTailDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedTailDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { +private: + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ self; +public: + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(const CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&) = delete; + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } + operator LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() && { LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return res; } + ~CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ& operator=(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return *this; } + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() { return &self; } + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() { return &self; } + const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() const { return &self; } + const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_PublicKeyTypeZZ { private: LDKCVec_C2Tuple_PublicKeyTypeZZ self; @@ -8053,6 +9378,36 @@ public: const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator ->() const { return &self; } }; +class CResult_OnionMessagePathNoneZ { +private: + LDKCResult_OnionMessagePathNoneZ self; +public: + CResult_OnionMessagePathNoneZ(const CResult_OnionMessagePathNoneZ&) = delete; + CResult_OnionMessagePathNoneZ(CResult_OnionMessagePathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); } + CResult_OnionMessagePathNoneZ(LDKCResult_OnionMessagePathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); } + operator LDKCResult_OnionMessagePathNoneZ() && { LDKCResult_OnionMessagePathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionMessagePathNoneZ)); return res; } + ~CResult_OnionMessagePathNoneZ() { CResult_OnionMessagePathNoneZ_free(self); } + CResult_OnionMessagePathNoneZ& operator=(CResult_OnionMessagePathNoneZ&& o) { CResult_OnionMessagePathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionMessagePathNoneZ)); return *this; } + LDKCResult_OnionMessagePathNoneZ* operator &() { return &self; } + LDKCResult_OnionMessagePathNoneZ* operator ->() { return &self; } + const LDKCResult_OnionMessagePathNoneZ* operator &() const { return &self; } + const LDKCResult_OnionMessagePathNoneZ* operator ->() const { return &self; } +}; +class CResult_RefundBolt12ParseErrorZ { +private: + LDKCResult_RefundBolt12ParseErrorZ self; +public: + CResult_RefundBolt12ParseErrorZ(const CResult_RefundBolt12ParseErrorZ&) = delete; + CResult_RefundBolt12ParseErrorZ(CResult_RefundBolt12ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RefundBolt12ParseErrorZ)); } + CResult_RefundBolt12ParseErrorZ(LDKCResult_RefundBolt12ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RefundBolt12ParseErrorZ)); } + operator LDKCResult_RefundBolt12ParseErrorZ() && { LDKCResult_RefundBolt12ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RefundBolt12ParseErrorZ)); return res; } + ~CResult_RefundBolt12ParseErrorZ() { CResult_RefundBolt12ParseErrorZ_free(self); } + CResult_RefundBolt12ParseErrorZ& operator=(CResult_RefundBolt12ParseErrorZ&& o) { CResult_RefundBolt12ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RefundBolt12ParseErrorZ)); return *this; } + LDKCResult_RefundBolt12ParseErrorZ* operator &() { return &self; } + LDKCResult_RefundBolt12ParseErrorZ* operator ->() { return &self; } + const LDKCResult_RefundBolt12ParseErrorZ* operator &() const { return &self; } + const LDKCResult_RefundBolt12ParseErrorZ* operator ->() const { return &self; } +}; class C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { private: LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ self; @@ -8098,6 +9453,21 @@ public: const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } }; +class CResult_OffersMessageDecodeErrorZ { +private: + LDKCResult_OffersMessageDecodeErrorZ self; +public: + CResult_OffersMessageDecodeErrorZ(const CResult_OffersMessageDecodeErrorZ&) = delete; + CResult_OffersMessageDecodeErrorZ(CResult_OffersMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); } + CResult_OffersMessageDecodeErrorZ(LDKCResult_OffersMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); } + operator LDKCResult_OffersMessageDecodeErrorZ() && { LDKCResult_OffersMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); return res; } + ~CResult_OffersMessageDecodeErrorZ() { CResult_OffersMessageDecodeErrorZ_free(self); } + CResult_OffersMessageDecodeErrorZ& operator=(CResult_OffersMessageDecodeErrorZ&& o) { CResult_OffersMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); return *this; } + LDKCResult_OffersMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_OffersMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OffersMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OffersMessageDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NoneAPIErrorZ { private: LDKCResult_NoneAPIErrorZ self; @@ -8113,20 +9483,20 @@ public: const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; } const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; } }; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +class CResult_Bolt12InvoiceFeaturesDecodeErrorZ { private: - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; + LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ self; public: - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(const CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&) = delete; - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } - operator LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ() && { LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return res; } - ~CResult_CounterpartyChannelTransactionParametersDecodeErrorZ() { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ& operator=(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return *this; } - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() { return &self; } - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } + CResult_Bolt12InvoiceFeaturesDecodeErrorZ(const CResult_Bolt12InvoiceFeaturesDecodeErrorZ&) = delete; + CResult_Bolt12InvoiceFeaturesDecodeErrorZ(CResult_Bolt12InvoiceFeaturesDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12InvoiceFeaturesDecodeErrorZ)); } + CResult_Bolt12InvoiceFeaturesDecodeErrorZ(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ)); } + operator LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ() && { LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ)); return res; } + ~CResult_Bolt12InvoiceFeaturesDecodeErrorZ() { CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(self); } + CResult_Bolt12InvoiceFeaturesDecodeErrorZ& operator=(CResult_Bolt12InvoiceFeaturesDecodeErrorZ&& o) { CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12InvoiceFeaturesDecodeErrorZ)); return *this; } + LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; } }; class CVec_NetAddressZ { private: @@ -8158,6 +9528,21 @@ public: const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_PublicKeyZ { +private: + LDKCVec_PublicKeyZ self; +public: + CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; + CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } + CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } + operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } + ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } + CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } + LDKCVec_PublicKeyZ* operator &() { return &self; } + LDKCVec_PublicKeyZ* operator ->() { return &self; } + const LDKCVec_PublicKeyZ* operator &() const { return &self; } + const LDKCVec_PublicKeyZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_usizeTransactionZZ { private: LDKCVec_C2Tuple_usizeTransactionZZ self; @@ -8173,20 +9558,50 @@ public: const LDKCVec_C2Tuple_usizeTransactionZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; } }; -class CVec_PublicKeyZ { +class CResult_TxRemoveInputDecodeErrorZ { private: - LDKCVec_PublicKeyZ self; + LDKCResult_TxRemoveInputDecodeErrorZ self; public: - CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; - CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } - CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } - operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } - ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } - CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } - LDKCVec_PublicKeyZ* operator &() { return &self; } - LDKCVec_PublicKeyZ* operator ->() { return &self; } - const LDKCVec_PublicKeyZ* operator &() const { return &self; } - const LDKCVec_PublicKeyZ* operator ->() const { return &self; } + CResult_TxRemoveInputDecodeErrorZ(const CResult_TxRemoveInputDecodeErrorZ&) = delete; + CResult_TxRemoveInputDecodeErrorZ(CResult_TxRemoveInputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); } + CResult_TxRemoveInputDecodeErrorZ(LDKCResult_TxRemoveInputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); } + operator LDKCResult_TxRemoveInputDecodeErrorZ() && { LDKCResult_TxRemoveInputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); return res; } + ~CResult_TxRemoveInputDecodeErrorZ() { CResult_TxRemoveInputDecodeErrorZ_free(self); } + CResult_TxRemoveInputDecodeErrorZ& operator=(CResult_TxRemoveInputDecodeErrorZ&& o) { CResult_TxRemoveInputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); return *this; } + LDKCResult_TxRemoveInputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxRemoveInputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +private: + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; +public: + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(const CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&) = delete; + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } + operator LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ() && { LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return res; } + ~CResult_CounterpartyChannelTransactionParametersDecodeErrorZ() { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ& operator=(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return *this; } + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() { return &self; } + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } +}; +class COption_PaymentIdZ { +private: + LDKCOption_PaymentIdZ self; +public: + COption_PaymentIdZ(const COption_PaymentIdZ&) = delete; + COption_PaymentIdZ(COption_PaymentIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentIdZ)); } + COption_PaymentIdZ(LDKCOption_PaymentIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentIdZ)); } + operator LDKCOption_PaymentIdZ() && { LDKCOption_PaymentIdZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentIdZ)); return res; } + ~COption_PaymentIdZ() { COption_PaymentIdZ_free(self); } + COption_PaymentIdZ& operator=(COption_PaymentIdZ&& o) { COption_PaymentIdZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentIdZ)); return *this; } + LDKCOption_PaymentIdZ* operator &() { return &self; } + LDKCOption_PaymentIdZ* operator ->() { return &self; } + const LDKCOption_PaymentIdZ* operator &() const { return &self; } + const LDKCOption_PaymentIdZ* operator ->() const { return &self; } }; class C2Tuple_u64u64Z { private: @@ -8233,6 +9648,21 @@ public: const LDKC2Tuple_u32TxOutZ* operator &() const { return &self; } const LDKC2Tuple_u32TxOutZ* operator ->() const { return &self; } }; +class CVec_UtxoZ { +private: + LDKCVec_UtxoZ self; +public: + CVec_UtxoZ(const CVec_UtxoZ&) = delete; + CVec_UtxoZ(CVec_UtxoZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UtxoZ)); } + CVec_UtxoZ(LDKCVec_UtxoZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UtxoZ)); } + operator LDKCVec_UtxoZ() && { LDKCVec_UtxoZ res = self; memset(&self, 0, sizeof(LDKCVec_UtxoZ)); return res; } + ~CVec_UtxoZ() { CVec_UtxoZ_free(self); } + CVec_UtxoZ& operator=(CVec_UtxoZ&& o) { CVec_UtxoZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_UtxoZ)); return *this; } + LDKCVec_UtxoZ* operator &() { return &self; } + LDKCVec_UtxoZ* operator ->() { return &self; } + const LDKCVec_UtxoZ* operator &() const { return &self; } + const LDKCVec_UtxoZ* operator ->() const { return &self; } +}; class CResult_PaymentSecretNoneZ { private: LDKCResult_PaymentSecretNoneZ self; @@ -8278,6 +9708,21 @@ public: const LDKCVec_PrivateRouteZ* operator &() const { return &self; } const LDKCVec_PrivateRouteZ* operator ->() const { return &self; } }; +class COption_i64Z { +private: + LDKCOption_i64Z self; +public: + COption_i64Z(const COption_i64Z&) = delete; + COption_i64Z(COption_i64Z&& o) : self(o.self) { memset(&o, 0, sizeof(COption_i64Z)); } + COption_i64Z(LDKCOption_i64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_i64Z)); } + operator LDKCOption_i64Z() && { LDKCOption_i64Z res = self; memset(&self, 0, sizeof(LDKCOption_i64Z)); return res; } + ~COption_i64Z() { COption_i64Z_free(self); } + COption_i64Z& operator=(COption_i64Z&& o) { COption_i64Z_free(self); self = o.self; memset(&o, 0, sizeof(COption_i64Z)); return *this; } + LDKCOption_i64Z* operator &() { return &self; } + LDKCOption_i64Z* operator ->() { return &self; } + const LDKCOption_i64Z* operator &() const { return &self; } + const LDKCOption_i64Z* operator ->() const { return &self; } +}; class CResult_BlindedPathNoneZ { private: LDKCResult_BlindedPathNoneZ self; @@ -8308,6 +9753,21 @@ public: const LDKCResult_ShutdownDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ShutdownDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_OfferBolt12ParseErrorZ { +private: + LDKCResult_OfferBolt12ParseErrorZ self; +public: + CResult_OfferBolt12ParseErrorZ(const CResult_OfferBolt12ParseErrorZ&) = delete; + CResult_OfferBolt12ParseErrorZ(CResult_OfferBolt12ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferBolt12ParseErrorZ)); } + CResult_OfferBolt12ParseErrorZ(LDKCResult_OfferBolt12ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferBolt12ParseErrorZ)); } + operator LDKCResult_OfferBolt12ParseErrorZ() && { LDKCResult_OfferBolt12ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferBolt12ParseErrorZ)); return res; } + ~CResult_OfferBolt12ParseErrorZ() { CResult_OfferBolt12ParseErrorZ_free(self); } + CResult_OfferBolt12ParseErrorZ& operator=(CResult_OfferBolt12ParseErrorZ&& o) { CResult_OfferBolt12ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferBolt12ParseErrorZ)); return *this; } + LDKCResult_OfferBolt12ParseErrorZ* operator &() { return &self; } + LDKCResult_OfferBolt12ParseErrorZ* operator ->() { return &self; } + const LDKCResult_OfferBolt12ParseErrorZ* operator &() const { return &self; } + const LDKCResult_OfferBolt12ParseErrorZ* operator ->() const { return &self; } +}; class CResult_TxOutUtxoLookupErrorZ { private: LDKCResult_TxOutUtxoLookupErrorZ self; @@ -8353,6 +9813,21 @@ public: const LDKCVec_PaymentPreimageZ* operator &() const { return &self; } const LDKCVec_PaymentPreimageZ* operator ->() const { return &self; } }; +class CResult_BigSizeDecodeErrorZ { +private: + LDKCResult_BigSizeDecodeErrorZ self; +public: + CResult_BigSizeDecodeErrorZ(const CResult_BigSizeDecodeErrorZ&) = delete; + CResult_BigSizeDecodeErrorZ(CResult_BigSizeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BigSizeDecodeErrorZ)); } + CResult_BigSizeDecodeErrorZ(LDKCResult_BigSizeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BigSizeDecodeErrorZ)); } + operator LDKCResult_BigSizeDecodeErrorZ() && { LDKCResult_BigSizeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BigSizeDecodeErrorZ)); return res; } + ~CResult_BigSizeDecodeErrorZ() { CResult_BigSizeDecodeErrorZ_free(self); } + CResult_BigSizeDecodeErrorZ& operator=(CResult_BigSizeDecodeErrorZ&& o) { CResult_BigSizeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BigSizeDecodeErrorZ)); return *this; } + LDKCResult_BigSizeDecodeErrorZ* operator &() { return &self; } + LDKCResult_BigSizeDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BigSizeDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BigSizeDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_PublicKeyErrorZ { private: LDKCResult_PublicKeyErrorZ self; @@ -8398,6 +9873,66 @@ public: const LDKCResult_NoneNoneZ* operator &() const { return &self; } const LDKCResult_NoneNoneZ* operator ->() const { return &self; } }; +class CResult_boolPeerHandleErrorZ { +private: + LDKCResult_boolPeerHandleErrorZ self; +public: + CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete; + CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); } + CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); } + operator LDKCResult_boolPeerHandleErrorZ() && { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; } + ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); } + CResult_boolPeerHandleErrorZ& operator=(CResult_boolPeerHandleErrorZ&& o) { CResult_boolPeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); return *this; } + LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; } + LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } +}; +class CResult_ChannelUpdateDecodeErrorZ { +private: + LDKCResult_ChannelUpdateDecodeErrorZ self; +public: + CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete; + CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); } + CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); } + operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; } + ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); } + CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; } + LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; } +}; +class CVec_APIErrorZ { +private: + LDKCVec_APIErrorZ self; +public: + CVec_APIErrorZ(const CVec_APIErrorZ&) = delete; + CVec_APIErrorZ(CVec_APIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_APIErrorZ)); } + CVec_APIErrorZ(LDKCVec_APIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_APIErrorZ)); } + operator LDKCVec_APIErrorZ() && { LDKCVec_APIErrorZ res = self; memset(&self, 0, sizeof(LDKCVec_APIErrorZ)); return res; } + ~CVec_APIErrorZ() { CVec_APIErrorZ_free(self); } + CVec_APIErrorZ& operator=(CVec_APIErrorZ&& o) { CVec_APIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_APIErrorZ)); return *this; } + LDKCVec_APIErrorZ* operator &() { return &self; } + LDKCVec_APIErrorZ* operator ->() { return &self; } + const LDKCVec_APIErrorZ* operator &() const { return &self; } + const LDKCVec_APIErrorZ* operator ->() const { return &self; } +}; +class COption_TxOutZ { +private: + LDKCOption_TxOutZ self; +public: + COption_TxOutZ(const COption_TxOutZ&) = delete; + COption_TxOutZ(COption_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_TxOutZ)); } + COption_TxOutZ(LDKCOption_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_TxOutZ)); } + operator LDKCOption_TxOutZ() && { LDKCOption_TxOutZ res = self; memset(&self, 0, sizeof(LDKCOption_TxOutZ)); return res; } + ~COption_TxOutZ() { COption_TxOutZ_free(self); } + COption_TxOutZ& operator=(COption_TxOutZ&& o) { COption_TxOutZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_TxOutZ)); return *this; } + LDKCOption_TxOutZ* operator &() { return &self; } + LDKCOption_TxOutZ* operator ->() { return &self; } + const LDKCOption_TxOutZ* operator &() const { return &self; } + const LDKCOption_TxOutZ* operator ->() const { return &self; } +}; class COption_ClosureReasonZ { private: LDKCOption_ClosureReasonZ self; @@ -8428,80 +9963,35 @@ public: const LDKCOption_u128Z* operator &() const { return &self; } const LDKCOption_u128Z* operator ->() const { return &self; } }; -class CVec_APIErrorZ { -private: - LDKCVec_APIErrorZ self; -public: - CVec_APIErrorZ(const CVec_APIErrorZ&) = delete; - CVec_APIErrorZ(CVec_APIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_APIErrorZ)); } - CVec_APIErrorZ(LDKCVec_APIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_APIErrorZ)); } - operator LDKCVec_APIErrorZ() && { LDKCVec_APIErrorZ res = self; memset(&self, 0, sizeof(LDKCVec_APIErrorZ)); return res; } - ~CVec_APIErrorZ() { CVec_APIErrorZ_free(self); } - CVec_APIErrorZ& operator=(CVec_APIErrorZ&& o) { CVec_APIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_APIErrorZ)); return *this; } - LDKCVec_APIErrorZ* operator &() { return &self; } - LDKCVec_APIErrorZ* operator ->() { return &self; } - const LDKCVec_APIErrorZ* operator &() const { return &self; } - const LDKCVec_APIErrorZ* operator ->() const { return &self; } -}; -class CResult_boolPeerHandleErrorZ { -private: - LDKCResult_boolPeerHandleErrorZ self; -public: - CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete; - CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); } - CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); } - operator LDKCResult_boolPeerHandleErrorZ() && { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; } - ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); } - CResult_boolPeerHandleErrorZ& operator=(CResult_boolPeerHandleErrorZ&& o) { CResult_boolPeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); return *this; } - LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; } - LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } -}; class CVec_AddressZ { private: LDKCVec_AddressZ self; -public: - CVec_AddressZ(const CVec_AddressZ&) = delete; - CVec_AddressZ(CVec_AddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_AddressZ)); } - CVec_AddressZ(LDKCVec_AddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_AddressZ)); } - operator LDKCVec_AddressZ() && { LDKCVec_AddressZ res = self; memset(&self, 0, sizeof(LDKCVec_AddressZ)); return res; } - ~CVec_AddressZ() { CVec_AddressZ_free(self); } - CVec_AddressZ& operator=(CVec_AddressZ&& o) { CVec_AddressZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_AddressZ)); return *this; } - LDKCVec_AddressZ* operator &() { return &self; } - LDKCVec_AddressZ* operator ->() { return &self; } - const LDKCVec_AddressZ* operator &() const { return &self; } - const LDKCVec_AddressZ* operator ->() const { return &self; } -}; -class CResult_ChannelUpdateDecodeErrorZ { -private: - LDKCResult_ChannelUpdateDecodeErrorZ self; -public: - CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete; - CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); } - CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); } - operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; } - ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); } - CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; } - LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; } +public: + CVec_AddressZ(const CVec_AddressZ&) = delete; + CVec_AddressZ(CVec_AddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_AddressZ)); } + CVec_AddressZ(LDKCVec_AddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_AddressZ)); } + operator LDKCVec_AddressZ() && { LDKCVec_AddressZ res = self; memset(&self, 0, sizeof(LDKCVec_AddressZ)); return res; } + ~CVec_AddressZ() { CVec_AddressZ_free(self); } + CVec_AddressZ& operator=(CVec_AddressZ&& o) { CVec_AddressZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_AddressZ)); return *this; } + LDKCVec_AddressZ* operator &() { return &self; } + LDKCVec_AddressZ* operator ->() { return &self; } + const LDKCVec_AddressZ* operator &() const { return &self; } + const LDKCVec_AddressZ* operator ->() const { return &self; } }; -class CResult_PaymentSecretAPIErrorZ { +class CResult_TransactionU16LenLimitedDecodeErrorZ { private: - LDKCResult_PaymentSecretAPIErrorZ self; + LDKCResult_TransactionU16LenLimitedDecodeErrorZ self; public: - CResult_PaymentSecretAPIErrorZ(const CResult_PaymentSecretAPIErrorZ&) = delete; - CResult_PaymentSecretAPIErrorZ(CResult_PaymentSecretAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentSecretAPIErrorZ)); } - CResult_PaymentSecretAPIErrorZ(LDKCResult_PaymentSecretAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentSecretAPIErrorZ)); } - operator LDKCResult_PaymentSecretAPIErrorZ() && { LDKCResult_PaymentSecretAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentSecretAPIErrorZ)); return res; } - ~CResult_PaymentSecretAPIErrorZ() { CResult_PaymentSecretAPIErrorZ_free(self); } - CResult_PaymentSecretAPIErrorZ& operator=(CResult_PaymentSecretAPIErrorZ&& o) { CResult_PaymentSecretAPIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentSecretAPIErrorZ)); return *this; } - LDKCResult_PaymentSecretAPIErrorZ* operator &() { return &self; } - LDKCResult_PaymentSecretAPIErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentSecretAPIErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentSecretAPIErrorZ* operator ->() const { return &self; } + CResult_TransactionU16LenLimitedDecodeErrorZ(const CResult_TransactionU16LenLimitedDecodeErrorZ&) = delete; + CResult_TransactionU16LenLimitedDecodeErrorZ(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); } + CResult_TransactionU16LenLimitedDecodeErrorZ(LDKCResult_TransactionU16LenLimitedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); } + operator LDKCResult_TransactionU16LenLimitedDecodeErrorZ() && { LDKCResult_TransactionU16LenLimitedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ)); return res; } + ~CResult_TransactionU16LenLimitedDecodeErrorZ() { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); } + CResult_TransactionU16LenLimitedDecodeErrorZ& operator=(CResult_TransactionU16LenLimitedDecodeErrorZ&& o) { CResult_TransactionU16LenLimitedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionU16LenLimitedDecodeErrorZ)); return *this; } + LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() { return &self; } + LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() const { return &self; } }; class CResult_CounterpartyForwardingInfoDecodeErrorZ { private: @@ -8518,6 +10008,21 @@ public: const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_OpenChannelV2DecodeErrorZ { +private: + LDKCResult_OpenChannelV2DecodeErrorZ self; +public: + CResult_OpenChannelV2DecodeErrorZ(const CResult_OpenChannelV2DecodeErrorZ&) = delete; + CResult_OpenChannelV2DecodeErrorZ(CResult_OpenChannelV2DecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OpenChannelV2DecodeErrorZ)); } + CResult_OpenChannelV2DecodeErrorZ(LDKCResult_OpenChannelV2DecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OpenChannelV2DecodeErrorZ)); } + operator LDKCResult_OpenChannelV2DecodeErrorZ() && { LDKCResult_OpenChannelV2DecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OpenChannelV2DecodeErrorZ)); return res; } + ~CResult_OpenChannelV2DecodeErrorZ() { CResult_OpenChannelV2DecodeErrorZ_free(self); } + CResult_OpenChannelV2DecodeErrorZ& operator=(CResult_OpenChannelV2DecodeErrorZ&& o) { CResult_OpenChannelV2DecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OpenChannelV2DecodeErrorZ)); return *this; } + LDKCResult_OpenChannelV2DecodeErrorZ* operator &() { return &self; } + LDKCResult_OpenChannelV2DecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OpenChannelV2DecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OpenChannelV2DecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_u32ScriptZ { private: LDKC2Tuple_u32ScriptZ self; @@ -8533,21 +10038,6 @@ public: const LDKC2Tuple_u32ScriptZ* operator &() const { return &self; } const LDKC2Tuple_u32ScriptZ* operator ->() const { return &self; } }; -class CResult_SignedRawInvoiceParseErrorZ { -private: - LDKCResult_SignedRawInvoiceParseErrorZ self; -public: - CResult_SignedRawInvoiceParseErrorZ(const CResult_SignedRawInvoiceParseErrorZ&) = delete; - CResult_SignedRawInvoiceParseErrorZ(CResult_SignedRawInvoiceParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignedRawInvoiceParseErrorZ)); } - CResult_SignedRawInvoiceParseErrorZ(LDKCResult_SignedRawInvoiceParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignedRawInvoiceParseErrorZ)); } - operator LDKCResult_SignedRawInvoiceParseErrorZ() && { LDKCResult_SignedRawInvoiceParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignedRawInvoiceParseErrorZ)); return res; } - ~CResult_SignedRawInvoiceParseErrorZ() { CResult_SignedRawInvoiceParseErrorZ_free(self); } - CResult_SignedRawInvoiceParseErrorZ& operator=(CResult_SignedRawInvoiceParseErrorZ&& o) { CResult_SignedRawInvoiceParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignedRawInvoiceParseErrorZ)); return *this; } - LDKCResult_SignedRawInvoiceParseErrorZ* operator &() { return &self; } - LDKCResult_SignedRawInvoiceParseErrorZ* operator ->() { return &self; } - const LDKCResult_SignedRawInvoiceParseErrorZ* operator &() const { return &self; } - const LDKCResult_SignedRawInvoiceParseErrorZ* operator ->() const { return &self; } -}; class COption_C2Tuple_EightU16sEightU16sZZ { private: LDKCOption_C2Tuple_EightU16sEightU16sZZ self; @@ -8593,6 +10083,21 @@ public: const LDKCOption_NoneZ* operator &() const { return &self; } const LDKCOption_NoneZ* operator ->() const { return &self; } }; +class CResult_TxAddOutputDecodeErrorZ { +private: + LDKCResult_TxAddOutputDecodeErrorZ self; +public: + CResult_TxAddOutputDecodeErrorZ(const CResult_TxAddOutputDecodeErrorZ&) = delete; + CResult_TxAddOutputDecodeErrorZ(CResult_TxAddOutputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); } + CResult_TxAddOutputDecodeErrorZ(LDKCResult_TxAddOutputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); } + operator LDKCResult_TxAddOutputDecodeErrorZ() && { LDKCResult_TxAddOutputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); return res; } + ~CResult_TxAddOutputDecodeErrorZ() { CResult_TxAddOutputDecodeErrorZ_free(self); } + CResult_TxAddOutputDecodeErrorZ& operator=(CResult_TxAddOutputDecodeErrorZ&& o) { CResult_TxAddOutputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); return *this; } + LDKCResult_TxAddOutputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxAddOutputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxAddOutputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxAddOutputDecodeErrorZ* operator ->() const { return &self; } +}; class COption_CVec_u8ZZ { private: LDKCOption_CVec_u8ZZ self; @@ -8609,99 +10114,6 @@ public: const LDKCOption_CVec_u8ZZ* operator ->() const { return &self; } }; -inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs) { - LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, first_hops, inflight_htlcs); - return ret; -} -inline LDK::CResult_RouteLightningErrorZ Router::find_route_with_id(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id) { - LDK::CResult_RouteLightningErrorZ ret = (self.find_route_with_id)(self.this_arg, payer, route_params, first_hops, inflight_htlcs, _payment_hash, _payment_id); - return ret; -} -inline void BroadcasterInterface::broadcast_transaction(struct LDKTransaction tx) { - (self.broadcast_transaction)(self.this_arg, tx); -} -inline uint32_t FeeEstimator::get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target) { - uint32_t ret = (self.get_est_sat_per_1000_weight)(self.this_arg, confirmation_target); - return ret; -} -inline void Listen::filtered_block_connected(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) { - (self.filtered_block_connected)(self.this_arg, header, txdata, height); -} -inline void Listen::block_connected(struct LDKu8slice block, uint32_t height) { - (self.block_connected)(self.this_arg, block, height); -} -inline void Listen::block_disconnected(const uint8_t (*header)[80], uint32_t height) { - (self.block_disconnected)(self.this_arg, header, height); -} -inline void Confirm::transactions_confirmed(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) { - (self.transactions_confirmed)(self.this_arg, header, txdata, height); -} -inline void Confirm::transaction_unconfirmed(const uint8_t (*txid)[32]) { - (self.transaction_unconfirmed)(self.this_arg, txid); -} -inline void Confirm::best_block_updated(const uint8_t (*header)[80], uint32_t height) { - (self.best_block_updated)(self.this_arg, header, height); -} -inline LDK::CVec_C2Tuple_TxidBlockHashZZ Confirm::get_relevant_txids() { - LDK::CVec_C2Tuple_TxidBlockHashZZ ret = (self.get_relevant_txids)(self.this_arg); - return ret; -} -inline LDK::ChannelMonitorUpdateStatus Watch::watch_channel(struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor) { - LDK::ChannelMonitorUpdateStatus ret = (self.watch_channel)(self.this_arg, funding_txo, monitor); - return ret; -} -inline LDK::ChannelMonitorUpdateStatus Watch::update_channel(struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update) { - LDK::ChannelMonitorUpdateStatus ret = (self.update_channel)(self.this_arg, funding_txo, update); - return ret; -} -inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Watch::release_pending_monitor_events() { - LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = (self.release_pending_monitor_events)(self.this_arg); - return ret; -} -inline void Filter::register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey) { - (self.register_tx)(self.this_arg, txid, script_pubkey); -} -inline void Filter::register_output(struct LDKWatchedOutput output) { - (self.register_output)(self.this_arg, output); -} -inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage) { - uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, source, target, usage); - return ret; -} -inline void Score::payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { - (self.payment_path_failed)(self.this_arg, path, short_channel_id); -} -inline void Score::payment_path_successful(const struct LDKPath *NONNULL_PTR path) { - (self.payment_path_successful)(self.this_arg, path); -} -inline void Score::probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { - (self.probe_failed)(self.this_arg, path, short_channel_id); -} -inline void Score::probe_successful(const struct LDKPath *NONNULL_PTR path) { - (self.probe_successful)(self.this_arg, path); -} -inline LDK::Score LockableScore::lock() { - LDK::Score ret = (self.lock)(self.this_arg); - return ret; -} -inline uint64_t CustomOnionMessageContents::tlv_type() { - uint64_t ret = (self.tlv_type)(self.this_arg); - return ret; -} -inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pending_msg_events() { - LDK::CVec_MessageSendEventZ ret = (self.get_and_clear_pending_msg_events)(self.this_arg); - return ret; -} -inline LDK::OnionMessage OnionMessageProvider::next_onion_message_for_peer(struct LDKPublicKey peer_node_id) { - LDK::OnionMessage ret = (self.next_onion_message_for_peer)(self.this_arg, peer_node_id); - return ret; -} -inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) { - (self.process_pending_events)(self.this_arg, handler); -} -inline void EventHandler::handle_event(struct LDKEvent event) { - (self.handle_event)(self.this_arg, event); -} inline LDKPublicKey ChannelSigner::get_per_commitment_point(uint64_t idx) { LDKPublicKey ret = (self.get_per_commitment_point)(self.this_arg, idx); return ret; @@ -8741,6 +10153,10 @@ inline LDK::CResult_SignatureNoneZ EcdsaChannelSigner::sign_justice_revoked_htlc LDK::CResult_SignatureNoneZ ret = (self.sign_justice_revoked_htlc)(self.this_arg, justice_tx, input, amount, per_commitment_key, htlc); return ret; } +inline LDK::CResult_SignatureNoneZ EcdsaChannelSigner::sign_holder_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, const struct LDKHTLCDescriptor *NONNULL_PTR htlc_descriptor) { + LDK::CResult_SignatureNoneZ ret = (self.sign_holder_htlc_transaction)(self.this_arg, htlc_tx, input, htlc_descriptor); + return ret; +} inline LDK::CResult_SignatureNoneZ EcdsaChannelSigner::sign_counterparty_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc) { LDK::CResult_SignatureNoneZ ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, htlc_tx, input, amount, per_commitment_point, htlc); return ret; @@ -8793,24 +10209,100 @@ inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ SignerProvider::read LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); return ret; } -inline LDK::CVec_u8Z SignerProvider::get_destination_script() { - LDK::CVec_u8Z ret = (self.get_destination_script)(self.this_arg); +inline LDK::CResult_ScriptNoneZ SignerProvider::get_destination_script() { + LDK::CResult_ScriptNoneZ ret = (self.get_destination_script)(self.this_arg); return ret; } -inline LDK::ShutdownScript SignerProvider::get_shutdown_scriptpubkey() { - LDK::ShutdownScript ret = (self.get_shutdown_scriptpubkey)(self.this_arg); +inline LDK::CResult_ShutdownScriptNoneZ SignerProvider::get_shutdown_scriptpubkey() { + LDK::CResult_ShutdownScriptNoneZ ret = (self.get_shutdown_scriptpubkey)(self.this_arg); return ret; } -inline LDK::CResult_COption_TypeZDecodeErrorZ CustomMessageReader::read(uint16_t message_type, struct LDKu8slice buffer) { - LDK::CResult_COption_TypeZDecodeErrorZ ret = (self.read)(self.this_arg, message_type, buffer); +inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs) { + LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, first_hops, inflight_htlcs); return ret; } -inline uint16_t Type::type_id() { - uint16_t ret = (self.type_id)(self.this_arg); +inline LDK::CResult_RouteLightningErrorZ Router::find_route_with_id(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id) { + LDK::CResult_RouteLightningErrorZ ret = (self.find_route_with_id)(self.this_arg, payer, route_params, first_hops, inflight_htlcs, _payment_hash, _payment_id); return ret; } -inline LDK::Str Type::debug_str() { - LDK::Str ret = (self.debug_str)(self.this_arg); +inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params) { + uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, source, target, usage, score_params); + return ret; +} +inline void Score::payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { + (self.payment_path_failed)(self.this_arg, path, short_channel_id); +} +inline void Score::payment_path_successful(const struct LDKPath *NONNULL_PTR path) { + (self.payment_path_successful)(self.this_arg, path); +} +inline void Score::probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { + (self.probe_failed)(self.this_arg, path, short_channel_id); +} +inline void Score::probe_successful(const struct LDKPath *NONNULL_PTR path) { + (self.probe_successful)(self.this_arg, path); +} +inline LDK::Score LockableScore::lock() { + LDK::Score ret = (self.lock)(self.this_arg); + return ret; +} +inline void Listen::filtered_block_connected(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) { + (self.filtered_block_connected)(self.this_arg, header, txdata, height); +} +inline void Listen::block_connected(struct LDKu8slice block, uint32_t height) { + (self.block_connected)(self.this_arg, block, height); +} +inline void Listen::block_disconnected(const uint8_t (*header)[80], uint32_t height) { + (self.block_disconnected)(self.this_arg, header, height); +} +inline void Confirm::transactions_confirmed(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) { + (self.transactions_confirmed)(self.this_arg, header, txdata, height); +} +inline void Confirm::transaction_unconfirmed(const uint8_t (*txid)[32]) { + (self.transaction_unconfirmed)(self.this_arg, txid); +} +inline void Confirm::best_block_updated(const uint8_t (*header)[80], uint32_t height) { + (self.best_block_updated)(self.this_arg, header, height); +} +inline LDK::CVec_C2Tuple_TxidCOption_BlockHashZZZ Confirm::get_relevant_txids() { + LDK::CVec_C2Tuple_TxidCOption_BlockHashZZZ ret = (self.get_relevant_txids)(self.this_arg); + return ret; +} +inline LDK::ChannelMonitorUpdateStatus Watch::watch_channel(struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor) { + LDK::ChannelMonitorUpdateStatus ret = (self.watch_channel)(self.this_arg, funding_txo, monitor); + return ret; +} +inline LDK::ChannelMonitorUpdateStatus Watch::update_channel(struct LDKOutPoint funding_txo, const struct LDKChannelMonitorUpdate *NONNULL_PTR update) { + LDK::ChannelMonitorUpdateStatus ret = (self.update_channel)(self.this_arg, funding_txo, update); + return ret; +} +inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Watch::release_pending_monitor_events() { + LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = (self.release_pending_monitor_events)(self.this_arg); + return ret; +} +inline void Filter::register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey) { + (self.register_tx)(self.this_arg, txid, script_pubkey); +} +inline void Filter::register_output(struct LDKWatchedOutput output) { + (self.register_output)(self.this_arg, output); +} +inline LDK::CResult_CoinSelectionNoneZ CoinSelectionSource::select_confirmed_utxos(struct LDKThirtyTwoBytes claim_id, struct LDKCVec_InputZ must_spend, struct LDKCVec_TxOutZ must_pay_to, uint32_t target_feerate_sat_per_1000_weight) { + LDK::CResult_CoinSelectionNoneZ ret = (self.select_confirmed_utxos)(self.this_arg, claim_id, must_spend, must_pay_to, target_feerate_sat_per_1000_weight); + return ret; +} +inline LDK::CResult_TransactionNoneZ CoinSelectionSource::sign_tx(struct LDKTransaction tx) { + LDK::CResult_TransactionNoneZ ret = (self.sign_tx)(self.this_arg, tx); + return ret; +} +inline LDK::CResult_CVec_UtxoZNoneZ WalletSource::list_confirmed_utxos() { + LDK::CResult_CVec_UtxoZNoneZ ret = (self.list_confirmed_utxos)(self.this_arg); + return ret; +} +inline LDK::CResult_ScriptNoneZ WalletSource::get_change_script() { + LDK::CResult_ScriptNoneZ ret = (self.get_change_script)(self.this_arg); + return ret; +} +inline LDK::CResult_TransactionNoneZ WalletSource::sign_tx(struct LDKTransaction tx) { + LDK::CResult_TransactionNoneZ ret = (self.sign_tx)(self.this_arg, tx); return ret; } inline LDK::CResult_NoneLightningErrorZ CustomMessageHandler::handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id) { @@ -8821,6 +10313,14 @@ inline LDK::CVec_C2Tuple_PublicKeyTypeZZ CustomMessageHandler::get_and_clear_pen LDK::CVec_C2Tuple_PublicKeyTypeZZ ret = (self.get_and_clear_pending_msg)(self.this_arg); return ret; } +inline LDK::NodeFeatures CustomMessageHandler::provided_node_features() { + LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg); + return ret; +} +inline LDK::InitFeatures CustomMessageHandler::provided_init_features(struct LDKPublicKey their_node_id) { + LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id); + return ret; +} inline uintptr_t SocketDescriptor::send_data(struct LDKu8slice data, bool resume_read) { uintptr_t ret = (self.send_data)(self.this_arg, data, resume_read); return ret; @@ -8836,17 +10336,6 @@ inline uint64_t SocketDescriptor::hash() { uint64_t ret = (self.hash)(self.this_arg); return ret; } -inline LDK::UtxoResult UtxoLookup::get_utxo(const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) { - LDK::UtxoResult ret = (self.get_utxo)(self.this_arg, genesis_hash, short_channel_id); - return ret; -} -inline void CustomOnionMessageHandler::handle_custom_message(struct LDKCustomOnionMessageContents msg) { - (self.handle_custom_message)(self.this_arg, msg); -} -inline LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ CustomOnionMessageHandler::read_custom_message(uint64_t message_type, struct LDKu8slice buffer) { - LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret = (self.read_custom_message)(self.this_arg, message_type, buffer); - return ret; -} inline LDK::CResult_NoneErrorZ Persister::persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager) { LDK::CResult_NoneErrorZ ret = (self.persist_manager)(self.this_arg, channel_manager); return ret; @@ -8862,9 +10351,15 @@ inline LDK::CResult_NoneErrorZ Persister::persist_scorer(const struct LDKWriteab inline void ChannelMessageHandler::handle_open_channel(struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg) { (self.handle_open_channel)(self.this_arg, their_node_id, msg); } +inline void ChannelMessageHandler::handle_open_channel_v2(struct LDKPublicKey their_node_id, const struct LDKOpenChannelV2 *NONNULL_PTR msg) { + (self.handle_open_channel_v2)(self.this_arg, their_node_id, msg); +} inline void ChannelMessageHandler::handle_accept_channel(struct LDKPublicKey their_node_id, const struct LDKAcceptChannel *NONNULL_PTR msg) { (self.handle_accept_channel)(self.this_arg, their_node_id, msg); } +inline void ChannelMessageHandler::handle_accept_channel_v2(struct LDKPublicKey their_node_id, const struct LDKAcceptChannelV2 *NONNULL_PTR msg) { + (self.handle_accept_channel_v2)(self.this_arg, their_node_id, msg); +} inline void ChannelMessageHandler::handle_funding_created(struct LDKPublicKey their_node_id, const struct LDKFundingCreated *NONNULL_PTR msg) { (self.handle_funding_created)(self.this_arg, their_node_id, msg); } @@ -8880,6 +10375,33 @@ inline void ChannelMessageHandler::handle_shutdown(struct LDKPublicKey their_nod inline void ChannelMessageHandler::handle_closing_signed(struct LDKPublicKey their_node_id, const struct LDKClosingSigned *NONNULL_PTR msg) { (self.handle_closing_signed)(self.this_arg, their_node_id, msg); } +inline void ChannelMessageHandler::handle_tx_add_input(struct LDKPublicKey their_node_id, const struct LDKTxAddInput *NONNULL_PTR msg) { + (self.handle_tx_add_input)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_add_output(struct LDKPublicKey their_node_id, const struct LDKTxAddOutput *NONNULL_PTR msg) { + (self.handle_tx_add_output)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_remove_input(struct LDKPublicKey their_node_id, const struct LDKTxRemoveInput *NONNULL_PTR msg) { + (self.handle_tx_remove_input)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_remove_output(struct LDKPublicKey their_node_id, const struct LDKTxRemoveOutput *NONNULL_PTR msg) { + (self.handle_tx_remove_output)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_complete(struct LDKPublicKey their_node_id, const struct LDKTxComplete *NONNULL_PTR msg) { + (self.handle_tx_complete)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_signatures(struct LDKPublicKey their_node_id, const struct LDKTxSignatures *NONNULL_PTR msg) { + (self.handle_tx_signatures)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_init_rbf(struct LDKPublicKey their_node_id, const struct LDKTxInitRbf *NONNULL_PTR msg) { + (self.handle_tx_init_rbf)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_ack_rbf(struct LDKPublicKey their_node_id, const struct LDKTxAckRbf *NONNULL_PTR msg) { + (self.handle_tx_ack_rbf)(self.this_arg, their_node_id, msg); +} +inline void ChannelMessageHandler::handle_tx_abort(struct LDKPublicKey their_node_id, const struct LDKTxAbort *NONNULL_PTR msg) { + (self.handle_tx_abort)(self.this_arg, their_node_id, msg); +} inline void ChannelMessageHandler::handle_update_add_htlc(struct LDKPublicKey their_node_id, const struct LDKUpdateAddHTLC *NONNULL_PTR msg) { (self.handle_update_add_htlc)(self.this_arg, their_node_id, msg); } @@ -8928,6 +10450,10 @@ inline LDK::InitFeatures ChannelMessageHandler::provided_init_features(struct LD LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id); return ret; } +inline LDK::COption_CVec_ChainHashZZ ChannelMessageHandler::get_genesis_hashes() { + LDK::COption_CVec_ChainHashZZ ret = (self.get_genesis_hashes)(self.this_arg); + return ret; +} inline LDK::CResult_boolLightningErrorZ RoutingMessageHandler::handle_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg) { LDK::CResult_boolLightningErrorZ ret = (self.handle_node_announcement)(self.this_arg, msg); return ret; @@ -9004,6 +10530,63 @@ inline void Logger::log(const struct LDKRecord *NONNULL_PTR record) { inline void FutureCallback::call() { (self.call)(self.this_arg); } +inline LDK::COption_OffersMessageZ OffersMessageHandler::handle_message(struct LDKOffersMessage message) { + LDK::COption_OffersMessageZ ret = (self.handle_message)(self.this_arg, message); + return ret; +} +inline void BroadcasterInterface::broadcast_transactions(struct LDKCVec_TransactionZ txs) { + (self.broadcast_transactions)(self.this_arg, txs); +} +inline uint32_t FeeEstimator::get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target) { + uint32_t ret = (self.get_est_sat_per_1000_weight)(self.this_arg, confirmation_target); + return ret; +} +inline uint64_t CustomOnionMessageContents::tlv_type() { + uint64_t ret = (self.tlv_type)(self.this_arg); + return ret; +} +inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pending_msg_events() { + LDK::CVec_MessageSendEventZ ret = (self.get_and_clear_pending_msg_events)(self.this_arg); + return ret; +} +inline LDK::OnionMessage OnionMessageProvider::next_onion_message_for_peer(struct LDKPublicKey peer_node_id) { + LDK::OnionMessage ret = (self.next_onion_message_for_peer)(self.this_arg, peer_node_id); + return ret; +} +inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) { + (self.process_pending_events)(self.this_arg, handler); +} +inline void EventHandler::handle_event(struct LDKEvent event) { + (self.handle_event)(self.this_arg, event); +} +inline LDK::CResult_COption_TypeZDecodeErrorZ CustomMessageReader::read(uint16_t message_type, struct LDKu8slice buffer) { + LDK::CResult_COption_TypeZDecodeErrorZ ret = (self.read)(self.this_arg, message_type, buffer); + return ret; +} +inline uint16_t Type::type_id() { + uint16_t ret = (self.type_id)(self.this_arg); + return ret; +} +inline LDK::Str Type::debug_str() { + LDK::Str ret = (self.debug_str)(self.this_arg); + return ret; +} +inline LDK::UtxoResult UtxoLookup::get_utxo(const uint8_t (*genesis_hash)[32], uint64_t short_channel_id) { + LDK::UtxoResult ret = (self.get_utxo)(self.this_arg, genesis_hash, short_channel_id); + return ret; +} +inline LDK::CResult_OnionMessagePathNoneZ MessageRouter::find_path(struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination) { + LDK::CResult_OnionMessagePathNoneZ ret = (self.find_path)(self.this_arg, sender, peers, destination); + return ret; +} +inline LDK::COption_CustomOnionMessageContentsZ CustomOnionMessageHandler::handle_custom_message(struct LDKCustomOnionMessageContents msg) { + LDK::COption_CustomOnionMessageContentsZ ret = (self.handle_custom_message)(self.this_arg, msg); + return ret; +} +inline LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ CustomOnionMessageHandler::read_custom_message(uint64_t message_type, struct LDKu8slice buffer) { + LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret = (self.read_custom_message)(self.this_arg, message_type, buffer); + return ret; +} inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) { LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_id, data, update_id); return ret; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index ad65e75..b98e1c3 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -128,6 +128,102 @@ pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { Clone::clone(&orig) } #[repr(C)] +/// The contents of CResult_RefundBolt12ParseErrorZ +pub union CResult_RefundBolt12ParseErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::refund::Refund, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, +} +#[repr(C)] +/// A CResult_RefundBolt12ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RefundBolt12ParseErrorZ { + /// The contents of this CResult_RefundBolt12ParseErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundBolt12ParseErrorZPtr, + /// Whether this CResult_RefundBolt12ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ in the success state. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_ok(o: crate::lightning::offers::refund::Refund) -> CResult_RefundBolt12ParseErrorZ { + CResult_RefundBolt12ParseErrorZ { + contents: CResult_RefundBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ in the error state. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_RefundBolt12ParseErrorZ { + CResult_RefundBolt12ParseErrorZ { + contents: CResult_RefundBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_is_ok(o: &CResult_RefundBolt12ParseErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundBolt12ParseErrorZ. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_free(_res: CResult_RefundBolt12ParseErrorZ) { } +impl Drop for CResult_RefundBolt12ParseErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RefundBolt12ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RefundBolt12ParseErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundBolt12ParseErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundBolt12ParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_clone(orig: &CResult_RefundBolt12ParseErrorZ) -> CResult_RefundBolt12ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_NoneAPIErrorZ pub union CResult_NoneAPIErrorZPtr { /// Note that this value is always NULL, as there are no contents in the OK variant @@ -312,6 +408,43 @@ impl Clone for CVec_APIErrorZ { } } #[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentSecretZ { + /// When we're in this state, this COption_PaymentSecretZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentSecretZ contains nothing + None +} +impl COption_PaymentSecretZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentSecretZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentSecretZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentSecretZ { + COption_PaymentSecretZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentSecretZ containing nothing +pub extern "C" fn COption_PaymentSecretZ_none() -> COption_PaymentSecretZ { + COption_PaymentSecretZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentSecretZ_free(_res: COption_PaymentSecretZ) { } +#[no_mangle] +/// Creates a new COption_PaymentSecretZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentSecretZ_clone(orig: &COption_PaymentSecretZ) -> COption_PaymentSecretZ { Clone::clone(&orig) } +#[repr(C)] /// A dynamically-allocated array of u8s of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_u8Z { @@ -491,101 +624,77 @@ impl Clone for CResult_RecipientOnionFieldsDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig: &CResult_RecipientOnionFieldsDecodeErrorZ) -> CResult_RecipientOnionFieldsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not -pub enum COption_HTLCClaimZ { - /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim - Some(crate::lightning::ln::chan_utils::HTLCClaim), - /// When we're in this state, this COption_HTLCClaimZ contains nothing - None -} -impl COption_HTLCClaimZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim -pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { - COption_HTLCClaimZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing nothing -pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { - COption_HTLCClaimZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state -pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } -#[repr(C)] -/// The contents of CResult_NoneNoneZ -pub union CResult_NoneNoneZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_BlindedPayInfoDecodeErrorZ +pub union CResult_BlindedPayInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneNoneZ represents the result of a fallible operation, -/// containing a () on success and a () on failure. +/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneNoneZ { - /// The contents of this CResult_NoneNoneZ, accessible via either +pub struct CResult_BlindedPayInfoDecodeErrorZ { + /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneNoneZPtr, - /// Whether this CResult_NoneNoneZ represents a success state. + pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, + /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the success state. -pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the error state. -pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneNoneZ. -pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } -impl Drop for CResult_NoneNoneZ { +/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } +impl Drop for CResult_BlindedPayInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_NoneNoneZ { - fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { +impl From> for CResult_BlindedPayInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneNoneZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedPayInfoDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedPayInfoDecodeErrorZPtr { err } }; Self { contents, @@ -593,59 +702,59 @@ impl From> for CResult_NoneNoneZ { } } } -impl Clone for CResult_NoneNoneZ { +impl Clone for CResult_BlindedPayInfoDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ which has the same data as `orig` +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ -pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ +pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, + pub result: *mut crate::lightning::sign::DelayedPaymentOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, - /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -653,13 +762,13 @@ pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } -impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -672,16 +781,16 @@ impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { } } } -impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -689,59 +798,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxCreationKeysDecodeErrorZ -pub union CResult_TxCreationKeysDecodeErrorZPtr { +/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ +pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, + pub result: *mut crate::lightning::sign::StaticPaymentOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxCreationKeysDecodeErrorZ { - /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either +pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxCreationKeysDecodeErrorZPtr, - /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. + pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -749,13 +858,13 @@ pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } -impl Drop for CResult_TxCreationKeysDecodeErrorZ { +/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -768,16 +877,16 @@ impl Drop for CResult_TxCreationKeysDecodeErrorZ { } } } -impl From> for CResult_TxCreationKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxCreationKeysDecodeErrorZPtr { result } + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxCreationKeysDecodeErrorZPtr { err } + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -785,59 +894,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelPublicKeysDecodeErrorZ -pub union CResult_ChannelPublicKeysDecodeErrorZPtr { +/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ +pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, + pub result: *mut crate::lightning::sign::SpendableOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelPublicKeysDecodeErrorZ { - /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either +pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, - /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. + pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -845,13 +954,13 @@ pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } -impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { +/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -864,16 +973,16 @@ impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelPublicKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelPublicKeysDecodeErrorZPtr { result } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelPublicKeysDecodeErrorZPtr { err } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -881,33 +990,125 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::sign::SpendableOutputDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SpendableOutputDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::sign::SpendableOutputDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_SpendableOutputDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::SpendableOutputDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_SpendableOutputDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } +impl Drop for CVec_SpendableOutputDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_SpendableOutputDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TxOutZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::TxOut, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TxOutZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TxOutZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } +impl Drop for CVec_TxOutZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_TxOutZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] #[derive(Clone)] /// An enum which can either contain a u32 or not -pub enum COption_u32Z { - /// When we're in this state, this COption_u32Z contains a u32 +pub enum COption_PackedLockTimeZ { + /// When we're in this state, this COption_PackedLockTimeZ contains a u32 Some(u32), - /// When we're in this state, this COption_u32Z contains nothing + /// When we're in this state, this COption_PackedLockTimeZ contains nothing None } -impl COption_u32Z { +impl COption_PackedLockTimeZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } @@ -919,94 +1120,132 @@ impl COption_u32Z { } } #[no_mangle] -/// Constructs a new COption_u32Z containing a u32 -pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { - COption_u32Z::Some(o) +/// Constructs a new COption_PackedLockTimeZ containing a u32 +pub extern "C" fn COption_PackedLockTimeZ_some(o: u32) -> COption_PackedLockTimeZ { + COption_PackedLockTimeZ::Some(o) } #[no_mangle] -/// Constructs a new COption_u32Z containing nothing -pub extern "C" fn COption_u32Z_none() -> COption_u32Z { - COption_u32Z::None +/// Constructs a new COption_PackedLockTimeZ containing nothing +pub extern "C" fn COption_PackedLockTimeZ_none() -> COption_PackedLockTimeZ { + COption_PackedLockTimeZ::None } #[no_mangle] /// Frees any resources associated with the u32, if we are in the Some state -pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +pub extern "C" fn COption_PackedLockTimeZ_free(_res: COption_PackedLockTimeZ) { } #[no_mangle] -/// Creates a new COption_u32Z which has the same data as `orig` +/// Creates a new COption_PackedLockTimeZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } +pub extern "C" fn COption_PackedLockTimeZ_clone(orig: &COption_PackedLockTimeZ) -> COption_PackedLockTimeZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ -pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PartiallySignedTransactionusizeZ { + /// The element at position 0 + pub a: crate::c_types::derived::CVec_u8Z, + /// The element at position 1 + pub b: usize, +} +impl From<(crate::c_types::derived::CVec_u8Z, usize)> for C2Tuple_PartiallySignedTransactionusizeZ { + fn from (tup: (crate::c_types::derived::CVec_u8Z, usize)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PartiallySignedTransactionusizeZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::derived::CVec_u8Z, usize) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PartiallySignedTransactionusizeZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_clone(orig: &C2Tuple_PartiallySignedTransactionusizeZ) -> C2Tuple_PartiallySignedTransactionusizeZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PartiallySignedTransactionusizeZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_new(a: crate::c_types::derived::CVec_u8Z, b: usize) -> C2Tuple_PartiallySignedTransactionusizeZ { + C2Tuple_PartiallySignedTransactionusizeZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PartiallySignedTransactionusizeZ. +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_free(_res: C2Tuple_PartiallySignedTransactionusizeZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ +pub union CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { - /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + /// The contents of this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, - /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr, + /// Whether this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ) -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_err() -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_is_ok(o: &CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } -impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_free(_res: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) { } +impl Drop for CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1014,124 +1253,133 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_clone(orig: &CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a or not -pub enum COption_NoneZ { - /// When we're in this state, this COption_NoneZ contains a - Some, - /// When we're in this state, this COption_NoneZ contains nothing - None +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PaymentPreimageZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_NoneZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_PaymentPreimageZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Constructs a new COption_NoneZ containing a -pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { - COption_NoneZ::Some +impl From> for CVec_PaymentPreimageZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Constructs a new COption_NoneZ containing nothing -pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { - COption_NoneZ::None +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PaymentPreimageZ_free(_res: CVec_PaymentPreimageZ) { } +impl Drop for CVec_PaymentPreimageZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PaymentPreimageZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources associated with the , if we are in the Some state -pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } #[repr(C)] -/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ -pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// The contents of CResult_NoneNoneZ +pub union CResult_NoneNoneZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneNoneZ represents the result of a fallible operation, +/// containing a () on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either +pub struct CResult_NoneNoneZ { + /// The contents of this CResult_NoneNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. + pub contents: CResult_NoneNoneZPtr, + /// Whether this CResult_NoneNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneNoneZ in the success state. +pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_NoneNoneZ in the error state. +pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +/// Frees any resources used by the CResult_NoneNoneZ. +pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } +impl Drop for CResult_NoneNoneZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneNoneZ { + fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneNoneZPtr { result: core::ptr::null_mut() } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_NoneNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1139,237 +1387,179 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ -pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::Signatures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SignatureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Signature, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_SignatureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_SignatureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SignatureZ_free(_res: CVec_SignatureZ) { } +impl Drop for CVec_SignatureZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTransactionParametersDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTransactionParametersDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelTransactionParametersDecodeErrorZ { +impl Clone for CVec_SignatureZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Signatures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_SignatureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Signature, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_SignatureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_SignatureCVec_SignatureZZ { + /// The element at position 0 + pub a: crate::c_types::Signature, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_SignatureZ, } -impl From> for CVec_SignatureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { + fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SignatureZ_free(_res: CVec_SignatureZ) { } -impl Drop for CVec_SignatureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl C2Tuple_SignatureCVec_SignatureZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { + (self.a, self.b) } } -impl Clone for CVec_SignatureZ { +impl Clone for C2Tuple_SignatureCVec_SignatureZZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ { + C2Tuple_SignatureCVec_SignatureZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } #[repr(C)] -/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ -pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ +pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, + /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } +impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1377,95 +1567,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ -pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_SignatureNoneZ +pub union CResult_SignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Signature, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Signature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_SignatureNoneZ { + /// The contents of this CResult_SignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_SignatureNoneZPtr, + /// Whether this CResult_SignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_SignatureNoneZ in the success state. +pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SignatureNoneZ in the error state. +pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SignatureNoneZ_is_ok(o: &CResult_SignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_SignatureNoneZ. +pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } +impl Drop for CResult_SignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } + CResult_SignatureNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1473,58 +1659,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignatureNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedClosingTransactionNoneZ -pub union CResult_TrustedClosingTransactionNoneZPtr { +/// The contents of CResult_PublicKeyNoneZ +pub union CResult_PublicKeyNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, + pub result: *mut crate::c_types::PublicKey, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. +/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::PublicKey on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedClosingTransactionNoneZ { - /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either +pub struct CResult_PublicKeyNoneZ { + /// The contents of this CResult_PublicKeyNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedClosingTransactionNoneZPtr, - /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. + pub contents: CResult_PublicKeyNoneZPtr, + /// Whether this CResult_PublicKeyNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the success state. +pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the error state. +pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -1532,13 +1718,13 @@ pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_Truste } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { +pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } -impl Drop for CResult_TrustedClosingTransactionNoneZ { +/// Frees any resources used by the CResult_PublicKeyNoneZ. +pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } +impl Drop for CResult_PublicKeyNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1548,16 +1734,16 @@ impl Drop for CResult_TrustedClosingTransactionNoneZ { } } } -impl From> for CResult_TrustedClosingTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PublicKeyNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedClosingTransactionNoneZPtr { result } + CResult_PublicKeyNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } + CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1565,78 +1751,128 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CommitmentTransactionDecodeErrorZ -pub union CResult_CommitmentTransactionDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::BigEndianScalar or not +pub enum COption_ScalarZ { + /// When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar + Some(crate::c_types::BigEndianScalar), + /// When we're in this state, this COption_ScalarZ contains nothing + None +} +impl COption_ScalarZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar +pub extern "C" fn COption_ScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_ScalarZ { + COption_ScalarZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ScalarZ containing nothing +pub extern "C" fn COption_ScalarZ_none() -> COption_ScalarZ { + COption_ScalarZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state +pub extern "C" fn COption_ScalarZ_free(_res: COption_ScalarZ) { } +#[no_mangle] +/// Creates a new COption_ScalarZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ScalarZ_clone(orig: &COption_ScalarZ) -> COption_ScalarZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SharedSecretNoneZ +pub union CResult_SharedSecretNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SharedSecretNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_SharedSecretNoneZ { + /// The contents of this CResult_SharedSecretNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_SharedSecretNoneZPtr, + /// Whether this CResult_SharedSecretNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_SharedSecretNoneZ in the success state. +pub extern "C" fn CResult_SharedSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_SharedSecretNoneZ { + CResult_SharedSecretNoneZ { + contents: CResult_SharedSecretNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SharedSecretNoneZ in the error state. +pub extern "C" fn CResult_SharedSecretNoneZ_err() -> CResult_SharedSecretNoneZ { + CResult_SharedSecretNoneZ { + contents: CResult_SharedSecretNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SharedSecretNoneZ_is_ok(o: &CResult_SharedSecretNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_CommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_SharedSecretNoneZ. +pub extern "C" fn CResult_SharedSecretNoneZ_free(_res: CResult_SharedSecretNoneZ) { } +impl Drop for CResult_SharedSecretNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_CommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SharedSecretNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentTransactionDecodeErrorZPtr { result } + CResult_SharedSecretNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SharedSecretNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1644,58 +1880,104 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SharedSecretNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SharedSecretNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SharedSecretNoneZ_clone(orig: &CResult_SharedSecretNoneZ) -> CResult_SharedSecretNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedCommitmentTransactionNoneZ -pub union CResult_TrustedCommitmentTransactionNoneZPtr { +/// A dynamically-allocated array of crate::c_types::U5s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_U5Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::U5, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_U5Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::U5] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_U5Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_U5Z_free(_res: CVec_U5Z) { } +impl Drop for CVec_U5Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_U5Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_RecoverableSignatureNoneZ +pub union CResult_RecoverableSignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, + pub result: *mut crate::c_types::RecoverableSignature, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. +/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::RecoverableSignature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedCommitmentTransactionNoneZ { - /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either +pub struct CResult_RecoverableSignatureNoneZ { + /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, - /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. + pub contents: CResult_RecoverableSignatureNoneZPtr, + /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -1703,13 +1985,13 @@ pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_Tru } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { +pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } -impl Drop for CResult_TrustedCommitmentTransactionNoneZ { +/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } +impl Drop for CResult_RecoverableSignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1719,16 +2001,16 @@ impl Drop for CResult_TrustedCommitmentTransactionNoneZ { } } } -impl From> for CResult_TrustedCommitmentTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RecoverableSignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedCommitmentTransactionNoneZPtr { result } + CResult_RecoverableSignatureNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } + CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1736,74 +2018,95 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_SignatureZNoneZ -pub union CResult_CVec_SignatureZNoneZPtr { +/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ +pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_SignatureZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::sign::WriteableEcdsaChannelSigner, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. +/// A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_SignatureZNoneZ { - /// The contents of this CResult_CVec_SignatureZNoneZ, accessible via either +pub struct CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + /// The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_SignatureZNoneZPtr, - /// Whether this CResult_CVec_SignatureZNoneZ represents a success state. + pub contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr, + /// Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ in the success state. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_ok(o: crate::c_types::derived::CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ { - CResult_CVec_SignatureZNoneZ { - contents: CResult_CVec_SignatureZNoneZPtr { +/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::sign::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ in the error state. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { - CResult_CVec_SignatureZNoneZ { - contents: CResult_CVec_SignatureZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_SignatureZNoneZ_is_ok(o: &CResult_CVec_SignatureZNoneZ) -> bool { +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_SignatureZNoneZ. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_free(_res: CResult_CVec_SignatureZNoneZ) { } -impl Drop for CResult_CVec_SignatureZNoneZ { +/// Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res: CResult_WriteableEcdsaChannelSignerDecodeErrorZ) { } +impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_SignatureZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_SignatureZNoneZPtr { result } + CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CVec_SignatureZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } }; Self { contents, @@ -1811,95 +2114,74 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_SignatureZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptDecodeErrorZ -pub union CResult_ShutdownScriptDecodeErrorZPtr { +/// The contents of CResult_ScriptNoneZ +pub union CResult_ScriptNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::script::ShutdownScript, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ScriptNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptDecodeErrorZ { - /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either +pub struct CResult_ScriptNoneZ { + /// The contents of this CResult_ScriptNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptDecodeErrorZPtr, - /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. + pub contents: CResult_ScriptNoneZPtr, + /// Whether this CResult_ScriptNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { +/// Creates a new CResult_ScriptNoneZ in the success state. +pub extern "C" fn CResult_ScriptNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_ScriptNoneZ { + CResult_ScriptNoneZ { + contents: CResult_ScriptNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ScriptNoneZ in the error state. +pub extern "C" fn CResult_ScriptNoneZ_err() -> CResult_ScriptNoneZ { + CResult_ScriptNoneZ { + contents: CResult_ScriptNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ScriptNoneZ_is_ok(o: &CResult_ScriptNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } -impl Drop for CResult_ShutdownScriptDecodeErrorZ { +/// Frees any resources used by the CResult_ScriptNoneZ. +pub extern "C" fn CResult_ScriptNoneZ_free(_res: CResult_ScriptNoneZ) { } +impl Drop for CResult_ScriptNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ShutdownScriptDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ScriptNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptDecodeErrorZPtr { result } + CResult_ScriptNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ScriptNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1907,95 +2189,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ScriptNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ScriptNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ScriptNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ScriptNoneZ_clone(orig: &CResult_ScriptNoneZ) -> CResult_ScriptNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ -pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// The contents of CResult_ShutdownScriptNoneZ +pub union CResult_ShutdownScriptNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. pub result: *mut crate::lightning::ln::script::ShutdownScript, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. +/// A CResult_ShutdownScriptNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { - /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either +pub struct CResult_ShutdownScriptNoneZ { + /// The contents of this CResult_ShutdownScriptNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, - /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. + pub contents: CResult_ShutdownScriptNoneZPtr, + /// Whether this CResult_ShutdownScriptNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// Creates a new CResult_ShutdownScriptNoneZ in the success state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ShutdownScriptNoneZ in the error state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_err() -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptNoneZ_is_ok(o: &CResult_ShutdownScriptNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } -impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { +/// Frees any resources used by the CResult_ShutdownScriptNoneZ. +pub extern "C" fn CResult_ShutdownScriptNoneZ_free(_res: CResult_ShutdownScriptNoneZ) { } +impl Drop for CResult_ShutdownScriptNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } + CResult_ShutdownScriptNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ShutdownScriptNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2003,95 +2281,137 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + Self { result_ok: true, contents: CResult_ShutdownScriptNoneZPtr { result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_BlindedPayInfoDecodeErrorZ -pub union CResult_BlindedPayInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_ShutdownScriptNoneZ_clone(orig: &CResult_ShutdownScriptNoneZ) -> CResult_ShutdownScriptNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPayInfoDecodeErrorZ { - /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, - /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CVec_u8ZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::CVec_u8Z, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +impl CVec_CVec_u8ZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CVec_u8ZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } +impl Drop for CVec_CVec_u8ZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CVec_u8ZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_CVec_u8ZZNoneZ +pub union CResult_CVec_CVec_u8ZZNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_CVec_u8ZZNoneZ { + /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, + /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_is_ok(o: &CResult_CVec_CVec_u8ZZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } -impl Drop for CResult_BlindedPayInfoDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } +impl Drop for CResult_CVec_CVec_u8ZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_BlindedPayInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_CVec_u8ZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPayInfoDecodeErrorZPtr { result } + CResult_CVec_CVec_u8ZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPayInfoDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_CVec_u8ZZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2099,90 +2419,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not -pub enum COption_WriteableScoreZ { - /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore - Some(crate::lightning::routing::scoring::WriteableScore), - /// When we're in this state, this COption_WriteableScoreZ contains nothing - None -} -impl COption_WriteableScoreZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore -pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { - COption_WriteableScoreZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing nothing -pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { - COption_WriteableScoreZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state -pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneErrorZ -pub union CResult_NoneErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_InMemorySignerDecodeErrorZ +pub union CResult_InMemorySignerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::sign::InMemorySigner, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::c_types::IOError on failure. +/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneErrorZ { - /// The contents of this CResult_NoneErrorZ, accessible via either +pub struct CResult_InMemorySignerDecodeErrorZ { + /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneErrorZPtr, - /// Whether this CResult_NoneErrorZ represents a success state. + pub contents: CResult_InMemorySignerDecodeErrorZPtr, + /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneErrorZ in the success state. -pub extern "C" fn CResult_NoneErrorZ_ok() -> CResult_NoneErrorZ { - CResult_NoneErrorZ { - contents: CResult_NoneErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::sign::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneErrorZ in the error state. -pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneErrorZ { - CResult_NoneErrorZ { - contents: CResult_NoneErrorZPtr { +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2190,15 +2479,18 @@ pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_ } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneErrorZ_is_ok(o: &CResult_NoneErrorZ) -> bool { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneErrorZ. -pub extern "C" fn CResult_NoneErrorZ_free(_res: CResult_NoneErrorZ) { } -impl Drop for CResult_NoneErrorZ { +/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2206,16 +2498,16 @@ impl Drop for CResult_NoneErrorZ { } } } -impl From> for CResult_NoneErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InMemorySignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneErrorZPtr { err } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -2223,141 +2515,91 @@ impl From> for CResult } } } -impl Clone for CResult_NoneErrorZ { +impl Clone for CResult_InMemorySignerDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneErrorZ which has the same data as `orig` +/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChannelDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_PartiallySignedTransactionNoneZ +pub union CResult_PartiallySignedTransactionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } -impl CVec_ChannelDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[repr(C)] +/// A CResult_PartiallySignedTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PartiallySignedTransactionNoneZ { + /// The contents of this CResult_PartiallySignedTransactionNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PartiallySignedTransactionNoneZPtr, + /// Whether this CResult_PartiallySignedTransactionNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PartiallySignedTransactionNoneZ in the success state. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_PartiallySignedTransactionNoneZ { + CResult_PartiallySignedTransactionNoneZ { + contents: CResult_PartiallySignedTransactionNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_ChannelDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_PartiallySignedTransactionNoneZ in the error state. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_err() -> CResult_PartiallySignedTransactionNoneZ { + CResult_PartiallySignedTransactionNoneZ { + contents: CResult_PartiallySignedTransactionNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } -impl Drop for CVec_ChannelDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChannelDetailsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_RouteLightningErrorZ -pub union CResult_RouteLightningErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, -} -#[repr(C)] -/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteLightningErrorZ { - /// The contents of this CResult_RouteLightningErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteLightningErrorZPtr, - /// Whether this CResult_RouteLightningErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the success state. -pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the error state. -pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_is_ok(o: &CResult_PartiallySignedTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteLightningErrorZ. -pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } -impl Drop for CResult_RouteLightningErrorZ { +/// Frees any resources used by the CResult_PartiallySignedTransactionNoneZ. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_free(_res: CResult_PartiallySignedTransactionNoneZ) { } +impl Drop for CResult_PartiallySignedTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PartiallySignedTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteLightningErrorZPtr { result } + CResult_PartiallySignedTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteLightningErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PartiallySignedTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2365,95 +2607,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PartiallySignedTransactionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PartiallySignedTransactionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_PartiallySignedTransactionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_clone(orig: &CResult_PartiallySignedTransactionNoneZ) -> CResult_PartiallySignedTransactionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InFlightHtlcsDecodeErrorZ -pub union CResult_InFlightHtlcsDecodeErrorZPtr { +/// The contents of CResult_TransactionNoneZ +pub union CResult_TransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::InFlightHtlcs, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Transaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Transaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InFlightHtlcsDecodeErrorZ { - /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either +pub struct CResult_TransactionNoneZ { + /// The contents of this CResult_TransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, - /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. + pub contents: CResult_TransactionNoneZPtr, + /// Whether this CResult_TransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { +/// Creates a new CResult_TransactionNoneZ in the success state. +pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionNoneZ in the error state. +pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionNoneZ_is_ok(o: &CResult_TransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } -impl Drop for CResult_InFlightHtlcsDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionNoneZ. +pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } +impl Drop for CResult_TransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_InFlightHtlcsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InFlightHtlcsDecodeErrorZPtr { result } + CResult_TransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InFlightHtlcsDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2461,59 +2699,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteHopDecodeErrorZ -pub union CResult_RouteHopDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHop, +/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not +pub enum COption_WriteableScoreZ { + /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore + Some(crate::lightning::routing::scoring::WriteableScore), + /// When we're in this state, this COption_WriteableScoreZ contains nothing + None +} +impl COption_WriteableScoreZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore +pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { + COption_WriteableScoreZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing nothing +pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { + COption_WriteableScoreZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state +pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } +#[repr(C)] +/// The contents of CResult_NoneErrorZ +pub union CResult_NoneErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::IOError, } #[repr(C)] -/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::c_types::IOError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHopDecodeErrorZ { - /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either +pub struct CResult_NoneErrorZ { + /// The contents of this CResult_NoneErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHopDecodeErrorZPtr, - /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. + pub contents: CResult_NoneErrorZPtr, + /// Whether this CResult_NoneErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneErrorZ in the success state. +pub extern "C" fn CResult_NoneErrorZ_ok() -> CResult_NoneErrorZ { + CResult_NoneErrorZ { + contents: CResult_NoneErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { +/// Creates a new CResult_NoneErrorZ in the error state. +pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneErrorZ { + CResult_NoneErrorZ { + contents: CResult_NoneErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2521,18 +2790,15 @@ pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneErrorZ_is_ok(o: &CResult_NoneErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } -impl Drop for CResult_RouteHopDecodeErrorZ { +/// Frees any resources used by the CResult_NoneErrorZ. +pub extern "C" fn CResult_NoneErrorZ_free(_res: CResult_NoneErrorZ) { } +impl Drop for CResult_NoneErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2540,16 +2806,16 @@ impl Drop for CResult_RouteHopDecodeErrorZ { } } } -impl From> for CResult_RouteHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHopDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHopDecodeErrorZPtr { err } + CResult_NoneErrorZPtr { err } }; Self { contents, @@ -2557,47 +2823,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BlindedHopZ { +pub struct CVec_ChannelDetailsZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::blinded_path::BlindedHop, + pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BlindedHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ChannelDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BlindedHopZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ChannelDetailsZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2605,14 +2871,14 @@ impl From> for CVec_BlindedHopZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } -impl Drop for CVec_BlindedHopZ { +pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } +impl Drop for CVec_ChannelDetailsZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_BlindedHopZ { +impl Clone for CVec_ChannelDetailsZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2621,41 +2887,41 @@ impl Clone for CVec_BlindedHopZ { } } #[repr(C)] -/// The contents of CResult_BlindedTailDecodeErrorZ -pub union CResult_BlindedTailDecodeErrorZPtr { +/// The contents of CResult_RouteLightningErrorZ +pub union CResult_RouteLightningErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::BlindedTail, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedTailDecodeErrorZ { - /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either +pub struct CResult_RouteLightningErrorZ { + /// The contents of this CResult_RouteLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedTailDecodeErrorZPtr, - /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. + pub contents: CResult_RouteLightningErrorZPtr, + /// Whether this CResult_RouteLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the success state. +pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the error state. +pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2663,13 +2929,13 @@ pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } -impl Drop for CResult_BlindedTailDecodeErrorZ { +/// Frees any resources used by the CResult_RouteLightningErrorZ. +pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } +impl Drop for CResult_RouteLightningErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2682,16 +2948,16 @@ impl Drop for CResult_BlindedTailDecodeErrorZ { } } } -impl From> for CResult_BlindedTailDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedTailDecodeErrorZPtr { result } + CResult_RouteLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedTailDecodeErrorZPtr { err } + CResult_RouteLightningErrorZPtr { err } }; Self { contents, @@ -2699,151 +2965,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } -impl Drop for CVec_RouteHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PathZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::Path, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PathZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PathZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } -impl Drop for CVec_PathZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PathZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteDecodeErrorZ -pub union CResult_RouteDecodeErrorZPtr { +/// The contents of CResult_InFlightHtlcsDecodeErrorZ +pub union CResult_InFlightHtlcsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, + pub result: *mut crate::lightning::routing::router::InFlightHtlcs, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteDecodeErrorZ { - /// The contents of this CResult_RouteDecodeErrorZ, accessible via either +pub struct CResult_InFlightHtlcsDecodeErrorZ { + /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteDecodeErrorZPtr, - /// Whether this CResult_RouteDecodeErrorZ represents a success state. + pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, + /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2851,13 +3025,13 @@ pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::D } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteDecodeErrorZ. -pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } -impl Drop for CResult_RouteDecodeErrorZ { +/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } +impl Drop for CResult_InFlightHtlcsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2870,16 +3044,16 @@ impl Drop for CResult_RouteDecodeErrorZ { } } } -impl From> for CResult_RouteDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InFlightHtlcsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteDecodeErrorZPtr { result } + CResult_InFlightHtlcsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteDecodeErrorZPtr { err } + CResult_InFlightHtlcsDecodeErrorZPtr { err } }; Self { contents, @@ -2887,59 +3061,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteParametersDecodeErrorZ -pub union CResult_RouteParametersDecodeErrorZPtr { +/// The contents of CResult_RouteHopDecodeErrorZ +pub union CResult_RouteHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteParameters, + pub result: *mut crate::lightning::routing::router::RouteHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteParametersDecodeErrorZ { - /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either +pub struct CResult_RouteHopDecodeErrorZ { + /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteParametersDecodeErrorZPtr, - /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. + pub contents: CResult_RouteHopDecodeErrorZPtr, + /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2947,13 +3121,13 @@ pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } -impl Drop for CResult_RouteParametersDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } +impl Drop for CResult_RouteHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2966,16 +3140,16 @@ impl Drop for CResult_RouteParametersDecodeErrorZ { } } } -impl From> for CResult_RouteParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteParametersDecodeErrorZPtr { result } + CResult_RouteHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteParametersDecodeErrorZPtr { err } + CResult_RouteHopDecodeErrorZPtr { err } }; Self { contents, @@ -2983,47 +3157,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of u64s of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_u64Z { +pub struct CVec_BlindedHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u64, + pub data: *mut crate::lightning::blinded_path::BlindedHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_u64Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_BlindedHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_u64Z { - fn from(v: Vec) -> Self { +impl From> for CVec_BlindedHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3031,14 +3205,14 @@ impl From> for CVec_u64Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } -impl Drop for CVec_u64Z { +pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } +impl Drop for CVec_BlindedHopZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_u64Z { +impl Clone for CVec_BlindedHopZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3047,41 +3221,41 @@ impl Clone for CVec_u64Z { } } #[repr(C)] -/// The contents of CResult_PaymentParametersDecodeErrorZ -pub union CResult_PaymentParametersDecodeErrorZPtr { +/// The contents of CResult_BlindedTailDecodeErrorZ +pub union CResult_BlindedTailDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::PaymentParameters, + pub result: *mut crate::lightning::routing::router::BlindedTail, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentParametersDecodeErrorZ { - /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either +pub struct CResult_BlindedTailDecodeErrorZ { + /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentParametersDecodeErrorZPtr, - /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub contents: CResult_BlindedTailDecodeErrorZPtr, + /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3089,13 +3263,13 @@ pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } -impl Drop for CResult_PaymentParametersDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } +impl Drop for CResult_BlindedTailDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3108,16 +3282,16 @@ impl Drop for CResult_PaymentParametersDecodeErrorZ { } } } -impl From> for CResult_PaymentParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedTailDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentParametersDecodeErrorZPtr { result } + CResult_BlindedTailDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentParametersDecodeErrorZPtr { err } + CResult_BlindedTailDecodeErrorZPtr { err } }; Self { contents, @@ -3125,89 +3299,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlindedPayInfoBlindedPathZ { - /// The element at position 0 - pub a: crate::lightning::offers::invoice::BlindedPayInfo, - /// The element at position 1 - pub b: crate::lightning::blinded_path::BlindedPath, -} -impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { - fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_BlindedPayInfoBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { - C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +pub struct CVec_RouteHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, + pub data: *mut crate::lightning::routing::router::RouteHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3215,14 +3347,14 @@ impl From> for } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res: CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) { } -impl Drop for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } +impl Drop for CVec_RouteHopZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +impl Clone for CVec_RouteHopZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3231,75 +3363,66 @@ impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHintZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHint, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a u32 or not +pub enum COption_u32Z { + /// When we're in this state, this COption_u32Z contains a u32 + Some(u32), + /// When we're in this state, this COption_u32Z contains nothing + None } -impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_u32Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_RouteHintZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> u32 { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } -impl Drop for CVec_RouteHintZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHintZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// Constructs a new COption_u32Z containing a u32 +pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { + COption_u32Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u32Z containing nothing +pub extern "C" fn COption_u32Z_none() -> COption_u32Z { + COption_u32Z::None } +#[no_mangle] +/// Frees any resources associated with the u32, if we are in the Some state +pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +#[no_mangle] +/// Creates a new COption_u32Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_RouteHintHopZ { +pub struct CVec_PathZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHintHop, + pub data: *mut crate::lightning::routing::router::Path, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_RouteHintHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_PathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_RouteHintHopZ { - fn from(v: Vec) -> Self { +impl From> for CVec_PathZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3307,14 +3430,14 @@ impl From> for CVec_RouteHi } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } -impl Drop for CVec_RouteHintHopZ { +pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } +impl Drop for CVec_PathZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_RouteHintHopZ { +impl Clone for CVec_PathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3323,41 +3446,41 @@ impl Clone for CVec_RouteHintHopZ { } } #[repr(C)] -/// The contents of CResult_RouteHintDecodeErrorZ -pub union CResult_RouteHintDecodeErrorZPtr { +/// The contents of CResult_RouteDecodeErrorZ +pub union CResult_RouteDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHint, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintDecodeErrorZ { - /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either +pub struct CResult_RouteDecodeErrorZ { + /// The contents of this CResult_RouteDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintDecodeErrorZPtr, - /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. + pub contents: CResult_RouteDecodeErrorZPtr, + /// Whether this CResult_RouteDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHint) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3365,13 +3488,13 @@ pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } -impl Drop for CResult_RouteHintDecodeErrorZ { +/// Frees any resources used by the CResult_RouteDecodeErrorZ. +pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } +impl Drop for CResult_RouteDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3384,16 +3507,16 @@ impl Drop for CResult_RouteHintDecodeErrorZ { } } } -impl From> for CResult_RouteHintDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintDecodeErrorZPtr { result } + CResult_RouteDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintDecodeErrorZPtr { err } + CResult_RouteDecodeErrorZPtr { err } }; Self { contents, @@ -3401,59 +3524,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteHintHopDecodeErrorZ -pub union CResult_RouteHintHopDecodeErrorZPtr { +/// The contents of CResult_RouteParametersDecodeErrorZ +pub union CResult_RouteParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHintHop, + pub result: *mut crate::lightning::routing::router::RouteParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintHopDecodeErrorZ { - /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either +pub struct CResult_RouteParametersDecodeErrorZ { + /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintHopDecodeErrorZPtr, - /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. + pub contents: CResult_RouteParametersDecodeErrorZPtr, + /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3461,13 +3584,13 @@ pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } -impl Drop for CResult_RouteHintHopDecodeErrorZ { +/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } +impl Drop for CResult_RouteParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3480,16 +3603,16 @@ impl Drop for CResult_RouteHintHopDecodeErrorZ { } } } -impl From> for CResult_RouteHintHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintHopDecodeErrorZPtr { result } + CResult_RouteParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintHopDecodeErrorZPtr { err } + CResult_RouteParametersDecodeErrorZPtr { err } }; Self { contents, @@ -3497,47 +3620,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// A dynamically-allocated array of u64s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PublicKeyZ { +pub struct CVec_u64Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::PublicKey, + pub data: *mut u64, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PublicKeyZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u64Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PublicKeyZ { - fn from(v: Vec) -> Self { +impl From> for CVec_u64Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3545,14 +3668,14 @@ impl From> for CVec_PublicKeyZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } -impl Drop for CVec_PublicKeyZ { +pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } +impl Drop for CVec_u64Z { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PublicKeyZ { +impl Clone for CVec_u64Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3561,115 +3684,123 @@ impl Clone for CVec_PublicKeyZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_usizeTransactionZ { - /// The element at position 0 - pub a: usize, - /// The element at position 1 - pub b: crate::c_types::Transaction, +/// The contents of CResult_PaymentParametersDecodeErrorZ +pub union CResult_PaymentParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::PaymentParameters, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { - fn from (tup: (usize, crate::c_types::Transaction)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentParametersDecodeErrorZ { + /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentParametersDecodeErrorZPtr, + /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_usizeTransactionZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_usizeTransactionZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { - C2Tuple_usizeTransactionZ { a, b, } +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_usizeTransactionZ. -pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_usizeTransactionZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_usizeTransactionZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } +impl Drop for CResult_PaymentParametersDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } -impl Drop for CVec_C2Tuple_usizeTransactionZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_PaymentParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PaymentParametersDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentParametersDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_C2Tuple_usizeTransactionZZ { +impl Clone for CResult_PaymentParametersDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidBlockHashZ { +pub struct C2Tuple_BlindedPayInfoBlindedPathZ { /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, + pub a: crate::lightning::offers::invoice::BlindedPayInfo, /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, + pub b: crate::lightning::blinded_path::BlindedPath, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_TxidBlockHashZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { +impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { + fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_TxidBlockHashZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { +impl C2Tuple_BlindedPayInfoBlindedPathZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { (self.a, self.b) } } -impl Clone for C2Tuple_TxidBlockHashZ { +impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -3680,40 +3811,40 @@ impl Clone for C2Tuple_TxidBlockHashZ { #[no_mangle] /// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidBlockHashZ_clone(orig: &C2Tuple_TxidBlockHashZ) -> C2Tuple_TxidBlockHashZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidBlockHashZ from the contained elements. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_TxidBlockHashZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_TxidBlockHashZ { - C2Tuple_TxidBlockHashZ { a, b, } +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { + C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_TxidBlockHashZ. -pub extern "C" fn C2Tuple_TxidBlockHashZ_free(_res: C2Tuple_TxidBlockHashZ) { } +/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidBlockHashZZ { +pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidBlockHashZ, + pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_TxidBlockHashZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidBlockHashZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_TxidBlockHashZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3721,14 +3852,14 @@ impl From> for CVec_C2Tuple } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidBlockHashZZ_free(_res: CVec_C2Tuple_TxidBlockHashZZ) { } -impl Drop for CVec_C2Tuple_TxidBlockHashZZ { +pub extern "C" fn CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res: CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) { } +impl Drop for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_TxidBlockHashZZ { +impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3737,29 +3868,29 @@ impl Clone for CVec_C2Tuple_TxidBlockHashZZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_MonitorEventZ { +pub struct CVec_RouteHintZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + pub data: *mut crate::lightning::routing::router::RouteHint, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_MonitorEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_MonitorEventZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHintZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3767,14 +3898,14 @@ impl From> for CVec_M } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } -impl Drop for CVec_MonitorEventZ { +pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } +impl Drop for CVec_RouteHintZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_MonitorEventZ { +impl Clone for CVec_RouteHintZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3783,75 +3914,29 @@ impl Clone for CVec_MonitorEventZ { } } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorEventZ, - /// The element at position 2 - pub c: crate::c_types::PublicKey, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +pub struct CVec_RouteHintHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + pub data: *mut crate::lightning::routing::router::RouteHintHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHintHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHintHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3859,14 +3944,14 @@ impl From Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3875,41 +3960,41 @@ impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { } } #[repr(C)] -/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ -pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// The contents of CResult_RouteHintDecodeErrorZ +pub union CResult_RouteHintDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + pub result: *mut crate::lightning::routing::router::RouteHint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FixedPenaltyScorerDecodeErrorZ { - /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either +pub struct CResult_RouteHintDecodeErrorZ { + /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, - /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + pub contents: CResult_RouteHintDecodeErrorZPtr, + /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHint) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3917,13 +4002,13 @@ pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } -impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } +impl Drop for CResult_RouteHintDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3936,16 +4021,16 @@ impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { } } } -impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHintDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FixedPenaltyScorerDecodeErrorZPtr { result } + CResult_RouteHintDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + CResult_RouteHintDecodeErrorZPtr { err } }; Self { contents, @@ -3953,223 +4038,261 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u64u64Z { - /// The element at position 0 - pub a: u64, - /// The element at position 1 - pub b: u64, -} -impl From<(u64, u64)> for C2Tuple_u64u64Z { - fn from (tup: (u64, u64)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u64u64Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u64u64Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_u64u64Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { - C2Tuple_u64u64Z { a, b, } +/// The contents of CResult_RouteHintHopDecodeErrorZ +pub union CResult_RouteHintHopDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::RouteHintHop, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u64u64Z. -pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not -pub enum COption_C2Tuple_u64u64ZZ { - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z - Some(crate::c_types::derived::C2Tuple_u64u64Z), - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing - None +/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RouteHintHopDecodeErrorZ { + /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RouteHintHopDecodeErrorZPtr, + /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl COption_C2Tuple_u64u64ZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { - if let Self::Some(v) = self { v } else { unreachable!() } +#[no_mangle] +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z -pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::Some(o) +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing -pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::None +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } -#[no_mangle] -/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, -} -impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, +/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } +impl Drop for CResult_RouteHintHopDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl C2Tuple_Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) +impl From> for CResult_RouteHintHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RouteHintHopDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RouteHintHopDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C2Tuple_Z { +impl Clone for CResult_RouteHintHopDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { - C2Tuple_Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_Z. -pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u168_u168Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, +/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PublicKeyZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::PublicKey, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl CVec_PublicKeyZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -impl C2Tuple__u168_u168Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl Clone for C2Tuple__u168_u168Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +impl From> for CVec_PublicKeyZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } -/// Creates a new C2Tuple__u168_u168Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { - C2Tuple__u168_u168Z { a, b, } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } +impl Drop for CVec_PublicKeyZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PublicKeyZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u168_u168Z. -pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not -pub enum COption_C2Tuple_EightU16sEightU16sZZ { - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z - Some(crate::c_types::derived::C2Tuple__u168_u168Z), - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing - None +/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ +pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl COption_C2Tuple_EightU16sEightU16sZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u168_u168Z { - if let Self::Some(v) = self { v } else { unreachable!() } +#[repr(C)] +/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FixedPenaltyScorerDecodeErrorZ { + /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, + /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::Some(o) +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::None +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } +/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } +impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FixedPenaltyScorerDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FixedPenaltyScorerDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} #[no_mangle] -/// Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. /// This corresponds to std::vector in C++ @@ -4217,216 +4340,241 @@ impl Clone for CVec_NodeIdZ { } } #[repr(C)] -/// The contents of CResult_ProbabilisticScorerDecodeErrorZ -pub union CResult_ProbabilisticScorerDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u64u64Z { + /// The element at position 0 + pub a: u64, + /// The element at position 1 + pub b: u64, } -#[repr(C)] -/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ProbabilisticScorerDecodeErrorZ { - /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, - /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. - pub result_ok: bool, +impl From<(u64, u64)> for C2Tuple_u64u64Z { + fn from (tup: (u64, u64)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } } -#[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl C2Tuple_u64u64Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { + (self.a, self.b) } } -#[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl Clone for C2Tuple_u64u64Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { - o.result_ok +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_u64u64Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { + C2Tuple_u64u64Z { a, b, } } + #[no_mangle] -/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } -impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources used by the C2Tuple_u64u64Z. +pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not +pub enum COption_C2Tuple_u64u64ZZ { + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + Some(crate::c_types::derived::C2Tuple_u64u64Z), + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + None } -impl From> for CResult_ProbabilisticScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ProbabilisticScorerDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ProbabilisticScorerDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl COption_C2Tuple_u64u64ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { + if let Self::Some(v) = self { v } else { unreachable!() } } } -#[repr(C)] -/// The contents of CResult_InitFeaturesDecodeErrorZ -pub union CResult_InitFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InitFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitFeaturesDecodeErrorZ { - /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitFeaturesDecodeErrorZPtr, - /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z +pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::Some(o) } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing +pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::None } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl C2Tuple_Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } } -#[no_mangle] -/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } +impl Clone for C2Tuple_Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } - }; +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { + C2Tuple_Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_Z. +pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u168_u168Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_InitFeaturesDecodeErrorZ { +impl C2Tuple__u168_u168Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } +} +impl Clone for C2Tuple__u168_u168Z { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } +/// Creates a new C2Tuple__u168_u168Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { + C2Tuple__u168_u168Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u168_u168Z. +pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not +pub enum COption_C2Tuple_EightU16sEightU16sZZ { + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z + Some(crate::c_types::derived::C2Tuple__u168_u168Z), + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing + None +} +impl COption_C2Tuple_EightU16sEightU16sZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u168_u168Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ProbabilisticScorerDecodeErrorZ +pub union CResult_ProbabilisticScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelFeatures, + pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either +pub struct CResult_ProbabilisticScorerDecodeErrorZ { + /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, + /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4434,13 +4582,13 @@ pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } +impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4453,16 +4601,16 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ProbabilisticScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelFeaturesDecodeErrorZPtr { result } + CResult_ProbabilisticScorerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelFeaturesDecodeErrorZPtr { err } + CResult_ProbabilisticScorerDecodeErrorZPtr { err } }; Self { contents, @@ -4470,347 +4618,393 @@ impl From for C2Tuple_usizeTransactionZ { + fn from (tup: (usize, crate::c_types::Transaction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_usizeTransactionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_usizeTransactionZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { + C2Tuple_usizeTransactionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_usizeTransactionZ. +pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } #[repr(C)] -/// The contents of CResult_NodeFeaturesDecodeErrorZ -pub union CResult_NodeFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::NodeFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeFeaturesDecodeErrorZ { - /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeFeaturesDecodeErrorZPtr, - /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_usizeTransactionZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_usizeTransactionZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } -impl Drop for CResult_NodeFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } +impl Drop for CVec_C2Tuple_usizeTransactionZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_NodeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeFeaturesDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_NodeFeaturesDecodeErrorZ { +impl Clone for CVec_C2Tuple_usizeTransactionZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_InvoiceFeaturesDecodeErrorZ -pub union CResult_InvoiceFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InvoiceFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} #[repr(C)] -/// A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceFeaturesDecodeErrorZ { - /// The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceFeaturesDecodeErrorZPtr, - /// Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_BlockHashZ { + /// When we're in this state, this COption_BlockHashZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_BlockHashZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InvoiceFeatures) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_BlockHashZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_BlockHashZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_BlockHashZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_BlockHashZ { + COption_BlockHashZ::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_InvoiceFeaturesDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_BlockHashZ containing nothing +pub extern "C" fn COption_BlockHashZ_none() -> COption_BlockHashZ { + COption_BlockHashZ::None } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_BlockHashZ_free(_res: COption_BlockHashZ) { } +#[no_mangle] +/// Creates a new COption_BlockHashZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_BlockHashZ_clone(orig: &COption_BlockHashZ) -> COption_BlockHashZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCOption_BlockHashZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::COption_BlockHashZ, } -impl From> for CResult_InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceFeaturesDecodeErrorZPtr { err } - }; +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ)> for C2Tuple_TxidCOption_BlockHashZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_InvoiceFeaturesDecodeErrorZ { +impl C2Tuple_TxidCOption_BlockHashZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_TxidCOption_BlockHashZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_InvoiceFeaturesDecodeErrorZ) -> CResult_InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ -pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_clone(orig: &C2Tuple_TxidCOption_BlockHashZZ) -> C2Tuple_TxidCOption_BlockHashZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCOption_BlockHashZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::COption_BlockHashZ) -> C2Tuple_TxidCOption_BlockHashZZ { + C2Tuple_TxidCOption_BlockHashZZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidCOption_BlockHashZZ. +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_free(_res: C2Tuple_TxidCOption_BlockHashZZ) { } #[repr(C)] -/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopFeaturesDecodeErrorZ { - /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, - /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidCOption_BlockHashZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_TxidCOption_BlockHashZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_TxidCOption_BlockHashZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } -impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidCOption_BlockHashZZZ_free(_res: CVec_C2Tuple_TxidCOption_BlockHashZZZ) { } +impl Drop for CVec_C2Tuple_TxidCOption_BlockHashZZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopFeaturesDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_TxidCOption_BlockHashZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MonitorEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MonitorEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MonitorEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } +impl Drop for CVec_MonitorEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_MonitorEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_MonitorEventZ, + /// The element at position 2 + pub c: crate::c_types::PublicKey, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, + c: tup.2, } } } -impl Clone for CResult_BlindedHopFeaturesDecodeErrorZ { +impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), } } } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } #[repr(C)] -/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ -pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res: CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ) { } +impl Drop for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_InitFeaturesDecodeErrorZ +pub union CResult_InitFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, + pub result: *mut crate::lightning::ln::features::InitFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either +pub struct CResult_InitFeaturesDecodeErrorZ { + /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_InitFeaturesDecodeErrorZPtr, + /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4818,13 +5012,13 @@ pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } +impl Drop for CResult_InitFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4837,16 +5031,16 @@ impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InitFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } + CResult_InitFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } + CResult_InitFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4854,73 +5048,73 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPurposeDecodeErrorZ -pub union CResult_PaymentPurposeDecodeErrorZPtr { +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentPurpose, + pub result: *mut crate::lightning::ln::features::ChannelFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentPurposeDecodeErrorZ { - /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either +pub struct CResult_ChannelFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentPurposeDecodeErrorZPtr, - /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. + pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } -impl Drop for CResult_PaymentPurposeDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4933,16 +5127,16 @@ impl Drop for CResult_PaymentPurposeDecodeErrorZ { } } } -impl From> for CResult_PaymentPurposeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPurposeDecodeErrorZPtr { result } + CResult_ChannelFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPurposeDecodeErrorZPtr { err } + CResult_ChannelFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4950,133 +5144,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not -pub enum COption_NetworkUpdateZ { - /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate - Some(crate::lightning::routing::gossip::NetworkUpdate), - /// When we're in this state, this COption_NetworkUpdateZ contains nothing - None -} -impl COption_NetworkUpdateZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate -pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing nothing -pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state -pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } -#[no_mangle] -/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PathFailure or not -pub enum COption_PathFailureZ { - /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure - Some(crate::lightning::events::PathFailure), - /// When we're in this state, this COption_PathFailureZ contains nothing - None -} -impl COption_PathFailureZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure -pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { - COption_PathFailureZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing nothing -pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { - COption_PathFailureZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state -pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } -#[no_mangle] -/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_PathFailureZDecodeErrorZ -pub union CResult_COption_PathFailureZDecodeErrorZPtr { +/// The contents of CResult_NodeFeaturesDecodeErrorZ +pub union CResult_NodeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_PathFailureZ, + pub result: *mut crate::lightning::ln::features::NodeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_PathFailureZDecodeErrorZ { - /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either +pub struct CResult_NodeFeaturesDecodeErrorZ { + /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, - /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. + pub contents: CResult_NodeFeaturesDecodeErrorZPtr, + /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5084,13 +5204,13 @@ pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } -impl Drop for CResult_COption_PathFailureZDecodeErrorZ { +/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } +impl Drop for CResult_NodeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5103,16 +5223,16 @@ impl Drop for CResult_COption_PathFailureZDecodeErrorZ { } } } -impl From> for CResult_COption_PathFailureZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_PathFailureZDecodeErrorZPtr { result } + CResult_NodeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_PathFailureZDecodeErrorZPtr { err } + CResult_NodeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5120,96 +5240,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::ClosureReason or not -pub enum COption_ClosureReasonZ { - /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason - Some(crate::lightning::events::ClosureReason), - /// When we're in this state, this COption_ClosureReasonZ contains nothing - None -} -impl COption_ClosureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason -pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { - COption_ClosureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing nothing -pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { - COption_ClosureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state -pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } -#[no_mangle] -/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ -pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, + pub result: *mut crate::lightning::ln::features::Bolt11InvoiceFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_ClosureReasonZDecodeErrorZ { - /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, - /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5217,13 +5300,13 @@ pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } -impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt11InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5236,16 +5319,16 @@ impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { } } } -impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_ClosureReasonZDecodeErrorZPtr { result } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_ClosureReasonZDecodeErrorZPtr { err } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5253,96 +5336,155 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::HTLCDestination or not -pub enum COption_HTLCDestinationZ { - /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination - Some(crate::lightning::events::HTLCDestination), - /// When we're in this state, this COption_HTLCDestinationZ contains nothing - None +/// The contents of CResult_Bolt12InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::Bolt12InvoiceFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl COption_HTLCDestinationZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { - if let Self::Some(v) = self { v } else { unreachable!() } +#[repr(C)] +/// A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt12InvoiceFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination -pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::Some(o) +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing nothing -pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::None +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state -pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +/// Frees any resources used by the CResult_Bolt12InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt12InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} #[no_mangle] -/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ -pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ +pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, + pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { - /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either +pub struct CResult_BlindedHopFeaturesDecodeErrorZ { + /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, - /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, + /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5350,13 +5492,13 @@ pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } -impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } +impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5369,16 +5511,16 @@ impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { } } } -impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } + CResult_BlindedHopFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } + CResult_BlindedHopFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5386,59 +5528,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentFailureReasonDecodeErrorZ -pub union CResult_PaymentFailureReasonDecodeErrorZPtr { +/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ +pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentFailureReason, + pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentFailureReasonDecodeErrorZ { - /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either +pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, - /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. + pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5446,13 +5588,13 @@ pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } -impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5465,16 +5607,16 @@ impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { } } } -impl From> for CResult_PaymentFailureReasonDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentFailureReasonDecodeErrorZPtr { result } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentFailureReasonDecodeErrorZPtr { err } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5482,216 +5624,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::U128 or not -pub enum COption_u128Z { - /// When we're in this state, this COption_u128Z contains a crate::c_types::U128 - Some(crate::c_types::U128), - /// When we're in this state, this COption_u128Z contains nothing - None +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChainHashZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_u128Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_ChainHashZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl From> for CVec_ChainHashZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Constructs a new COption_u128Z containing a crate::c_types::U128 -pub extern "C" fn COption_u128Z_some(o: crate::c_types::U128) -> COption_u128Z { - COption_u128Z::Some(o) +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChainHashZ_free(_res: CVec_ChainHashZ) { } +impl Drop for CVec_ChainHashZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } -#[no_mangle] -/// Constructs a new COption_u128Z containing nothing -pub extern "C" fn COption_u128Z_none() -> COption_u128Z { - COption_u128Z::None +impl Clone for CVec_ChainHashZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state -pub extern "C" fn COption_u128Z_free(_res: COption_u128Z) { } -#[no_mangle] -/// Creates a new COption_u128Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not -pub enum COption_PaymentFailureReasonZ { - /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason - Some(crate::lightning::events::PaymentFailureReason), - /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing - None -} -impl COption_PaymentFailureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason -pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing nothing -pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state -pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } -#[no_mangle] -/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_SpendableOutputDescriptorZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_SpendableOutputDescriptorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_SpendableOutputDescriptorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } -impl Drop for CVec_SpendableOutputDescriptorZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_SpendableOutputDescriptorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::Event or not -pub enum COption_EventZ { - /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event - Some(crate::lightning::events::Event), - /// When we're in this state, this COption_EventZ contains nothing - None -} -impl COption_EventZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_EventZ containing a crate::lightning::events::Event -pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { - COption_EventZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_EventZ containing nothing -pub extern "C" fn COption_EventZ_none() -> COption_EventZ { - COption_EventZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state -pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } -#[no_mangle] -/// Creates a new COption_EventZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_COption_EventZDecodeErrorZ -pub union CResult_COption_EventZDecodeErrorZPtr { +/// The contents of CResult_OfferBolt12ParseErrorZ +pub union CResult_OfferBolt12ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_EventZ, + pub result: *mut crate::lightning::offers::offer::Offer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, } #[repr(C)] -/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_EventZDecodeErrorZ { - /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either +pub struct CResult_OfferBolt12ParseErrorZ { + /// The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_EventZDecodeErrorZPtr, - /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + pub contents: CResult_OfferBolt12ParseErrorZPtr, + /// Whether this CResult_OfferBolt12ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the success state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the error state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5699,13 +5730,13 @@ pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_is_ok(o: &CResult_OfferBolt12ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } -impl Drop for CResult_COption_EventZDecodeErrorZ { +/// Frees any resources used by the CResult_OfferBolt12ParseErrorZ. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_free(_res: CResult_OfferBolt12ParseErrorZ) { } +impl Drop for CResult_OfferBolt12ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5718,16 +5749,16 @@ impl Drop for CResult_COption_EventZDecodeErrorZ { } } } -impl From> for CResult_COption_EventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferBolt12ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_EventZDecodeErrorZPtr { result } + CResult_OfferBolt12ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_EventZDecodeErrorZPtr { err } + CResult_OfferBolt12ParseErrorZPtr { err } }; Self { contents, @@ -5735,115 +5766,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OfferBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OfferBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MessageSendEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::MessageSendEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MessageSendEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MessageSendEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } -impl Drop for CVec_MessageSendEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MessageSendEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChainHashZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ChainHashZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ChainHashZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChainHashZ_free(_res: CVec_ChainHashZ) { } -impl Drop for CVec_ChainHashZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChainHashZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_clone(orig: &CResult_OfferBolt12ParseErrorZ) -> CResult_OfferBolt12ParseErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_PublicKeyErrorZ pub union CResult_PublicKeyErrorZPtr { @@ -6037,21 +5976,58 @@ impl Clone for CResult_NodeIdDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NodeIdDecodeErrorZ_clone(orig: &CResult_NodeIdDecodeErrorZ) -> CResult_NodeIdDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ -pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not +pub enum COption_NetworkUpdateZ { + /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate + Some(crate::lightning::routing::gossip::NetworkUpdate), + /// When we're in this state, this COption_NetworkUpdateZ contains nothing + None } -#[repr(C)] -/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { - /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either +impl COption_NetworkUpdateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate +pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_NetworkUpdateZ containing nothing +pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state +pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } +#[no_mangle] +/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ +pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { + /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. pub contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr, /// Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. @@ -6165,6 +6141,98 @@ pub extern "C" fn COption_UtxoLookupZ_none() -> COption_UtxoLookupZ { /// Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state pub extern "C" fn COption_UtxoLookupZ_free(_res: COption_UtxoLookupZ) { } #[repr(C)] +/// The contents of CResult_NoneLightningErrorZ +pub union CResult_NoneLightningErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::LightningError, +} +#[repr(C)] +/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneLightningErrorZ { + /// The contents of this CResult_NoneLightningErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneLightningErrorZPtr, + /// Whether this CResult_NoneLightningErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ in the success state. +pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ in the error state. +pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneLightningErrorZ. +pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } +impl Drop for CResult_NoneLightningErrorZ { + fn drop(&mut self) { + if self.result_ok { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NoneLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneLightningErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneLightningErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_boolLightningErrorZ pub union CResult_boolLightningErrorZPtr { /// A pointer to the contents in the success state. @@ -6344,97 +6412,51 @@ pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig: &COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneLightningErrorZ -pub union CResult_NoneLightningErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, -} -#[repr(C)] -/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneLightningErrorZ { - /// The contents of this CResult_NoneLightningErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneLightningErrorZPtr, - /// Whether this CResult_NoneLightningErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageSendEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::MessageSendEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the success state. -pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, +impl CVec_MessageSendEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the error state. -pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { - o.result_ok +impl From> for CVec_MessageSendEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_NoneLightningErrorZ. -pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } -impl Drop for CResult_NoneLightningErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } +impl Drop for CVec_MessageSendEventZ { fn drop(&mut self) { - if self.result_ok { - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_NoneLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneLightningErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_NoneLightningErrorZ { +impl Clone for CVec_MessageSendEventZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_ChannelUpdateInfoDecodeErrorZ pub union CResult_ChannelUpdateInfoDecodeErrorZPtr { @@ -7174,77 +7196,331 @@ pub extern "C" fn COption_CVec_NetAddressZZ_free(_res: COption_CVec_NetAddressZZ /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_CVec_NetAddressZZ_clone(orig: &COption_CVec_NetAddressZZ) -> COption_CVec_NetAddressZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ -pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentPreimageZ { + /// When we're in this state, this COption_PaymentPreimageZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentPreimageZ contains nothing + None +} +impl COption_PaymentPreimageZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentPreimageZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentPreimageZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentPreimageZ { + COption_PaymentPreimageZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentPreimageZ containing nothing +pub extern "C" fn COption_PaymentPreimageZ_none() -> COption_PaymentPreimageZ { + COption_PaymentPreimageZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentPreimageZ_free(_res: COption_PaymentPreimageZ) { } +#[no_mangle] +/// Creates a new COption_PaymentPreimageZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentPreimageZ_clone(orig: &COption_PaymentPreimageZ) -> COption_PaymentPreimageZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A dynamically-allocated array of crate::lightning::ln::chan_utils::HTLCOutputInCommitments of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCOutputInCommitmentZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_HTLCOutputInCommitmentZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::HTLCOutputInCommitment] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_HTLCOutputInCommitmentZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCOutputInCommitmentZ_free(_res: CVec_HTLCOutputInCommitmentZ) { } +impl Drop for CVec_HTLCOutputInCommitmentZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_HTLCOutputInCommitmentZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::HTLCDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::HTLCDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_HTLCDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::HTLCDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_HTLCDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCDescriptorZ_free(_res: CVec_HTLCDescriptorZ) { } +impl Drop for CVec_HTLCDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_HTLCDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Utxos of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UtxoZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Utxo, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UtxoZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Utxo] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UtxoZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UtxoZ_free(_res: CVec_UtxoZ) { } +impl Drop for CVec_UtxoZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UtxoZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::TxOut or not +pub enum COption_TxOutZ { + /// When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut + Some(crate::c_types::TxOut), + /// When we're in this state, this COption_TxOutZ contains nothing + None +} +impl COption_TxOutZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::TxOut { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing a crate::c_types::TxOut +pub extern "C" fn COption_TxOutZ_some(o: crate::c_types::TxOut) -> COption_TxOutZ { + COption_TxOutZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing nothing +pub extern "C" fn COption_TxOutZ_none() -> COption_TxOutZ { + COption_TxOutZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::TxOut, if we are in the Some state +pub extern "C" fn COption_TxOutZ_free(_res: COption_TxOutZ) { } +#[no_mangle] +/// Creates a new COption_TxOutZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_TxOutZ_clone(orig: &COption_TxOutZ) -> COption_TxOutZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Inputs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_InputZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Input, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_InputZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Input] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_InputZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_InputZ_free(_res: CVec_InputZ) { } +impl Drop for CVec_InputZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_InputZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CoinSelectionNoneZ +pub union CResult_CoinSelectionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::events::bump_transaction::CoinSelection, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_CoinSelectionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::events::bump_transaction::CoinSelection on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_CoinSelectionNoneZ { + /// The contents of this CResult_CoinSelectionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_CoinSelectionNoneZPtr, + /// Whether this CResult_CoinSelectionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_CoinSelectionNoneZ in the success state. +pub extern "C" fn CResult_CoinSelectionNoneZ_ok(o: crate::lightning::events::bump_transaction::CoinSelection) -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CoinSelectionNoneZ in the error state. +pub extern "C" fn CResult_CoinSelectionNoneZ_err() -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CoinSelectionNoneZ_is_ok(o: &CResult_CoinSelectionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_CoinSelectionNoneZ. +pub extern "C" fn CResult_CoinSelectionNoneZ_free(_res: CResult_CoinSelectionNoneZ) { } +impl Drop for CResult_CoinSelectionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CoinSelectionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } + CResult_CoinSelectionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CoinSelectionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -7252,95 +7528,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CoinSelectionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CoinSelectionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CoinSelectionNoneZ_clone(orig: &CResult_CoinSelectionNoneZ) -> CResult_CoinSelectionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ -pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +/// The contents of CResult_CVec_UtxoZNoneZ +pub union CResult_CVec_UtxoZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_UtxoZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_UtxoZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_UtxoZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_CVec_UtxoZNoneZ { + /// The contents of this CResult_CVec_UtxoZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_CVec_UtxoZNoneZPtr, + /// Whether this CResult_CVec_UtxoZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_CVec_UtxoZNoneZ in the success state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_ok(o: crate::c_types::derived::CVec_UtxoZ) -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_UtxoZNoneZ in the error state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_err() -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_UtxoZNoneZ_is_ok(o: &CResult_CVec_UtxoZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_UtxoZNoneZ. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_free(_res: CResult_CVec_UtxoZNoneZ) { } +impl Drop for CResult_CVec_UtxoZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_UtxoZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } + CResult_CVec_UtxoZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_UtxoZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -7348,59 +7620,170 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_UtxoZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_UtxoZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_UtxoZNoneZ_clone(orig: &CResult_CVec_UtxoZNoneZ) -> CResult_CVec_UtxoZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ -pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a u16 or not +pub enum COption_u16Z { + /// When we're in this state, this COption_u16Z contains a u16 + Some(u16), + /// When we're in this state, this COption_u16Z contains nothing + None +} +impl COption_u16Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> u16 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u16Z containing a u16 +pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { + COption_u16Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u16Z containing nothing +pub extern "C" fn COption_u16Z_none() -> COption_u16Z { + COption_u16Z::None +} +#[no_mangle] +/// Frees any resources associated with the u16, if we are in the Some state +pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } +#[no_mangle] +/// Creates a new COption_u16Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channelmanager::ChannelShutdownState or not +pub enum COption_ChannelShutdownStateZ { + /// When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channelmanager::ChannelShutdownState + Some(crate::lightning::ln::channelmanager::ChannelShutdownState), + /// When we're in this state, this COption_ChannelShutdownStateZ contains nothing + None +} +impl COption_ChannelShutdownStateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channelmanager::ChannelShutdownState { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channelmanager::ChannelShutdownState +pub extern "C" fn COption_ChannelShutdownStateZ_some(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing nothing +pub extern "C" fn COption_ChannelShutdownStateZ_none() -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channelmanager::ChannelShutdownState, if we are in the Some state +pub extern "C" fn COption_ChannelShutdownStateZ_free(_res: COption_ChannelShutdownStateZ) { } +#[no_mangle] +/// Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ChannelShutdownStateZ_clone(orig: &COption_ChannelShutdownStateZ) -> COption_ChannelShutdownStateZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentHashZ { + /// When we're in this state, this COption_PaymentHashZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentHashZ contains nothing + None +} +impl COption_PaymentHashZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentHashZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentHashZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentHashZ { + COption_PaymentHashZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentHashZ containing nothing +pub extern "C" fn COption_PaymentHashZ_none() -> COption_PaymentHashZ { + COption_PaymentHashZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentHashZ_free(_res: COption_PaymentHashZ) { } +#[no_mangle] +/// Creates a new COption_PaymentHashZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentHashZ_clone(orig: &COption_PaymentHashZ) -> COption_PaymentHashZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult__u832APIErrorZ +pub union CResult__u832APIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult__u832APIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult__u832APIErrorZ { + /// The contents of this CResult__u832APIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult__u832APIErrorZPtr, + /// Whether this CResult__u832APIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult__u832APIErrorZ in the success state. +pub extern "C" fn CResult__u832APIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832APIErrorZ { + CResult__u832APIErrorZ { + contents: CResult__u832APIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult__u832APIErrorZ in the error state. +pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult__u832APIErrorZ { + CResult__u832APIErrorZ { + contents: CResult__u832APIErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7408,13 +7791,13 @@ pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::li } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult__u832APIErrorZ_is_ok(o: &CResult__u832APIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult__u832APIErrorZ. +pub extern "C" fn CResult__u832APIErrorZ_free(_res: CResult__u832APIErrorZ) { } +impl Drop for CResult__u832APIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7427,16 +7810,16 @@ impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { } } } -impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult__u832APIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } + CResult__u832APIErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } + CResult__u832APIErrorZPtr { err } }; Self { contents, @@ -7444,47 +7827,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult__u832APIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult__u832APIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult__u832APIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult__u832APIErrorZ_clone(orig: &CResult__u832APIErrorZ) -> CResult__u832APIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PaymentPreimageZ { +pub struct CVec_RecentPaymentDetailsZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, + pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PaymentPreimageZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RecentPaymentDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PaymentPreimageZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RecentPaymentDetailsZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -7492,131 +7875,81 @@ impl From> for CVec_PaymentPreimageZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PaymentPreimageZ_free(_res: CVec_PaymentPreimageZ) { } -impl Drop for CVec_PaymentPreimageZ { +pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } +impl Drop for CVec_RecentPaymentDetailsZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PaymentPreimageZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_SignatureCVec_SignatureZZ { - /// The element at position 0 - pub a: crate::c_types::Signature, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_SignatureZ, -} -impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { - fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_SignatureCVec_SignatureZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_SignatureCVec_SignatureZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ { - C2Tuple_SignatureCVec_SignatureZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } #[repr(C)] -/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ -pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_NonePaymentSendFailureZ +pub union CResult_NonePaymentSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. +/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either +pub struct CResult_NonePaymentSendFailureZ { + /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, - /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + pub contents: CResult_NonePaymentSendFailureZPtr, + /// Whether this CResult_NonePaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePaymentSendFailureZ in the success state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } -} +/// Creates a new CResult_NonePaymentSendFailureZ in the error state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> bool { +pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } -impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +/// Frees any resources used by the CResult_NonePaymentSendFailureZ. +pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } +impl Drop for CResult_NonePaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NonePaymentSendFailureZPtr { err } }; Self { contents, @@ -7624,91 +7957,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignatureNoneZ -pub union CResult_SignatureNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Signature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_NoneRetryableSendFailureZ +pub union CResult_NoneRetryableSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } #[repr(C)] -/// A CResult_SignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Signature on success and a () on failure. +/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignatureNoneZ { - /// The contents of this CResult_SignatureNoneZ, accessible via either +pub struct CResult_NoneRetryableSendFailureZ { + /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignatureNoneZPtr, - /// Whether this CResult_SignatureNoneZ represents a success state. + pub contents: CResult_NoneRetryableSendFailureZPtr, + /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the success state. -pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the error state. -pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignatureNoneZ_is_ok(o: &CResult_SignatureNoneZ) -> bool { +pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignatureNoneZ. -pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } -impl Drop for CResult_SignatureNoneZ { +/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } +impl Drop for CResult_NoneRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_SignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignatureNoneZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_SignatureNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneRetryableSendFailureZPtr { err } }; Self { contents, @@ -7716,91 +8049,95 @@ impl From> for CResu } } } -impl Clone for CResult_SignatureNoneZ { +impl Clone for CResult_NoneRetryableSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_SignatureNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PublicKeyNoneZ -pub union CResult_PublicKeyNoneZPtr { +/// The contents of CResult_PaymentHashPaymentSendFailureZ +pub union CResult_PaymentHashPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::PublicKey, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a () on failure. +/// A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PublicKeyNoneZ { - /// The contents of this CResult_PublicKeyNoneZ, accessible via either +pub struct CResult_PaymentHashPaymentSendFailureZ { + /// The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PublicKeyNoneZPtr, - /// Whether this CResult_PublicKeyNoneZ represents a success state. + pub contents: CResult_PaymentHashPaymentSendFailureZPtr, + /// Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the success state. -pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the error state. -pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_is_ok(o: &CResult_PaymentHashPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PublicKeyNoneZ. -pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } -impl Drop for CResult_PublicKeyNoneZ { +/// Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_free(_res: CResult_PaymentHashPaymentSendFailureZ) { } +impl Drop for CResult_PaymentHashPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_PublicKeyNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentHashPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PublicKeyNoneZPtr { result } + CResult_PaymentHashPaymentSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentHashPaymentSendFailureZPtr { err } }; Self { contents, @@ -7808,128 +8145,95 @@ impl From> for CResu } } } -impl Clone for CResult_PublicKeyNoneZ { +impl Clone for CResult_PaymentHashPaymentSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentHashPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::BigEndianScalar or not -pub enum COption_ScalarZ { - /// When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar - Some(crate::c_types::BigEndianScalar), - /// When we're in this state, this COption_ScalarZ contains nothing - None +/// The contents of CResult_PaymentHashRetryableSendFailureZ +pub union CResult_PaymentHashRetryableSendFailureZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } -impl COption_ScalarZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { - if let Self::Some(v) = self { v } else { unreachable!() } - } +#[repr(C)] +/// A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentHashRetryableSendFailureZ { + /// The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentHashRetryableSendFailureZPtr, + /// Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar -pub extern "C" fn COption_ScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_ScalarZ { - COption_ScalarZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_ScalarZ containing nothing -pub extern "C" fn COption_ScalarZ_none() -> COption_ScalarZ { - COption_ScalarZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state -pub extern "C" fn COption_ScalarZ_free(_res: COption_ScalarZ) { } -#[no_mangle] -/// Creates a new COption_ScalarZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ScalarZ_clone(orig: &COption_ScalarZ) -> COption_ScalarZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_SharedSecretNoneZ -pub union CResult_SharedSecretNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} -#[repr(C)] -/// A CResult_SharedSecretNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SharedSecretNoneZ { - /// The contents of this CResult_SharedSecretNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SharedSecretNoneZPtr, - /// Whether this CResult_SharedSecretNoneZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ in the success state. -pub extern "C" fn CResult_SharedSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_SharedSecretNoneZ { - CResult_SharedSecretNoneZ { - contents: CResult_SharedSecretNoneZPtr { +/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashRetryableSendFailureZ { + CResult_PaymentHashRetryableSendFailureZ { + contents: CResult_PaymentHashRetryableSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ in the error state. -pub extern "C" fn CResult_SharedSecretNoneZ_err() -> CResult_SharedSecretNoneZ { - CResult_SharedSecretNoneZ { - contents: CResult_SharedSecretNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_PaymentHashRetryableSendFailureZ { + CResult_PaymentHashRetryableSendFailureZ { + contents: CResult_PaymentHashRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SharedSecretNoneZ_is_ok(o: &CResult_SharedSecretNoneZ) -> bool { +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_is_ok(o: &CResult_PaymentHashRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SharedSecretNoneZ. -pub extern "C" fn CResult_SharedSecretNoneZ_free(_res: CResult_SharedSecretNoneZ) { } -impl Drop for CResult_SharedSecretNoneZ { +/// Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_free(_res: CResult_PaymentHashRetryableSendFailureZ) { } +impl Drop for CResult_PaymentHashRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_SharedSecretNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentHashRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SharedSecretNoneZPtr { result } + CResult_PaymentHashRetryableSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_SharedSecretNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentHashRetryableSendFailureZPtr { err } }; Self { contents, @@ -7937,137 +8241,137 @@ impl From> for } } } -impl Clone for CResult_SharedSecretNoneZ { +impl Clone for CResult_PaymentHashRetryableSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SharedSecretNoneZPtr { + Self { result_ok: true, contents: CResult_PaymentHashRetryableSendFailureZPtr { result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SharedSecretNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentHashRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SharedSecretNoneZ_clone(orig: &CResult_SharedSecretNoneZ) -> CResult_SharedSecretNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_clone(orig: &CResult_PaymentHashRetryableSendFailureZ) -> CResult_PaymentHashRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::U5s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_U5Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::U5, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_U5Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::U5] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PaymentHashPaymentIdZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, } -impl From> for CVec_U5Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentIdZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_U5Z_free(_res: CVec_U5Z) { } -impl Drop for CVec_U5Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl C2Tuple_PaymentHashPaymentIdZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) } } -impl Clone for CVec_U5Z { +impl Clone for C2Tuple_PaymentHashPaymentIdZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_clone(orig: &C2Tuple_PaymentHashPaymentIdZ) -> C2Tuple_PaymentHashPaymentIdZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentIdZ { + C2Tuple_PaymentHashPaymentIdZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_free(_res: C2Tuple_PaymentHashPaymentIdZ) { } #[repr(C)] -/// The contents of CResult_RecoverableSignatureNoneZ -pub union CResult_RecoverableSignatureNoneZPtr { +/// The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ +pub union CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::RecoverableSignature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::RecoverableSignature on success and a () on failure. +/// A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RecoverableSignatureNoneZ { - /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either +pub struct CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + /// The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RecoverableSignatureNoneZPtr, - /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. + pub contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr, + /// Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } -impl Drop for CResult_RecoverableSignatureNoneZ { +/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) { } +impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_RecoverableSignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RecoverableSignatureNoneZPtr { result } + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { err } }; Self { contents, @@ -8075,126 +8379,47 @@ impl From } } } -impl Clone for CResult_RecoverableSignatureNoneZ { +impl Clone for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ -pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ThirtyTwoBytesZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - /// The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr, - /// Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res: CResult_WriteableEcdsaChannelSignerDecodeErrorZ) { } -impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_CVec_u8ZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CVec_u8Z, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_CVec_u8ZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ThirtyTwoBytesZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_CVec_u8ZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ThirtyTwoBytesZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -8202,14 +8427,14 @@ impl From> for CVec_CVec_u8ZZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } -impl Drop for CVec_CVec_u8ZZ { +pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } +impl Drop for CVec_ThirtyTwoBytesZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_CVec_u8ZZ { +impl Clone for CVec_ThirtyTwoBytesZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -8218,40 +8443,82 @@ impl Clone for CVec_CVec_u8ZZ { } } #[repr(C)] -/// The contents of CResult_CVec_CVec_u8ZZNoneZ -pub union CResult_CVec_CVec_u8ZZNoneZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PaymentHashPaymentSecretZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentSecretZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PaymentHashPaymentSecretZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PaymentHashPaymentSecretZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ { + C2Tuple_PaymentHashPaymentSecretZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_free(_res: C2Tuple_PaymentHashPaymentSecretZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ +pub union CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, + pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. +/// A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_CVec_u8ZZNoneZ { - /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either +pub struct CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, - /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr, + /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -8259,13 +8526,13 @@ pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNon } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_is_ok(o: &CResult_CVec_CVec_u8ZZNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } -impl Drop for CResult_CVec_CVec_u8ZZNoneZ { +/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) { } +impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8275,16 +8542,16 @@ impl Drop for CResult_CVec_CVec_u8ZZNoneZ { } } } -impl From> for CResult_CVec_CVec_u8ZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_CVec_u8ZZNoneZPtr { result } + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_CVec_u8ZZNoneZPtr { err: core::ptr::null_mut() } + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -8292,95 +8559,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InMemorySignerDecodeErrorZ -pub union CResult_InMemorySignerDecodeErrorZPtr { +/// The contents of CResult_PaymentSecretNoneZ +pub union CResult_PaymentSecretNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::InMemorySigner, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentSecretNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InMemorySignerDecodeErrorZ { - /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either +pub struct CResult_PaymentSecretNoneZ { + /// The contents of this CResult_PaymentSecretNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InMemorySignerDecodeErrorZPtr, - /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + pub contents: CResult_PaymentSecretNoneZPtr, + /// Whether this CResult_PaymentSecretNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { +/// Creates a new CResult_PaymentSecretNoneZ in the success state. +pub extern "C" fn CResult_PaymentSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretNoneZ { + CResult_PaymentSecretNoneZ { + contents: CResult_PaymentSecretNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_PaymentSecretNoneZ in the error state. +pub extern "C" fn CResult_PaymentSecretNoneZ_err() -> CResult_PaymentSecretNoneZ { + CResult_PaymentSecretNoneZ { + contents: CResult_PaymentSecretNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentSecretNoneZ_is_ok(o: &CResult_PaymentSecretNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } -impl Drop for CResult_InMemorySignerDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentSecretNoneZ. +pub extern "C" fn CResult_PaymentSecretNoneZ_free(_res: CResult_PaymentSecretNoneZ) { } +impl Drop for CResult_PaymentSecretNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_InMemorySignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentSecretNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InMemorySignerDecodeErrorZPtr { result } + CResult_PaymentSecretNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InMemorySignerDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -8388,137 +8651,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentSecretNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TxOutZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::TxOut, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TxOutZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_TxOutZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } -impl Drop for CVec_TxOutZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_TxOutZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_PaymentSecretNoneZ_clone(orig: &CResult_PaymentSecretNoneZ) -> CResult_PaymentSecretNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionNoneZ -pub union CResult_TransactionNoneZPtr { +/// The contents of CResult_PaymentPreimageAPIErrorZ +pub union CResult_PaymentPreimageAPIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Transaction, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_TransactionNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Transaction on success and a () on failure. +/// A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TransactionNoneZ { - /// The contents of this CResult_TransactionNoneZ, accessible via either +pub struct CResult_PaymentPreimageAPIErrorZ { + /// The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionNoneZPtr, - /// Whether this CResult_TransactionNoneZ represents a success state. + pub contents: CResult_PaymentPreimageAPIErrorZPtr, + /// Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the success state. -pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { +/// Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentPreimageAPIErrorZ { + CResult_PaymentPreimageAPIErrorZ { + contents: CResult_PaymentPreimageAPIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the error state. -pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentPreimageAPIErrorZ { + CResult_PaymentPreimageAPIErrorZ { + contents: CResult_PaymentPreimageAPIErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TransactionNoneZ_is_ok(o: &CResult_TransactionNoneZ) -> bool { +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_is_ok(o: &CResult_PaymentPreimageAPIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionNoneZ. -pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } -impl Drop for CResult_TransactionNoneZ { +/// Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_free(_res: CResult_PaymentPreimageAPIErrorZ) { } +impl Drop for CResult_PaymentPreimageAPIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_TransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentPreimageAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TransactionNoneZPtr { result } + CResult_PaymentPreimageAPIErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TransactionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentPreimageAPIErrorZPtr { err } }; Self { contents, @@ -8526,127 +8747,96 @@ impl From> for CRe } } } -impl Clone for CResult_TransactionNoneZ { +impl Clone for CResult_PaymentPreimageAPIErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPreimageAPIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentPreimageAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_clone(orig: &CResult_PaymentPreimageAPIErrorZ) -> CResult_PaymentPreimageAPIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelMonitorZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::CVec_ChainHashZ or not +pub enum COption_CVec_ChainHashZZ { + /// When we're in this state, this COption_CVec_ChainHashZZ contains a crate::c_types::derived::CVec_ChainHashZ + Some(crate::c_types::derived::CVec_ChainHashZ), + /// When we're in this state, this COption_CVec_ChainHashZZ contains nothing + None } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_CVec_ChainHashZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_BlockHashChannelMonitorZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_ChainHashZ { + if let Self::Some(v) = self { v } else { unreachable!() } } } -/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { - C2Tuple_BlockHashChannelMonitorZ { a, b, } +/// Constructs a new COption_CVec_ChainHashZZ containing a crate::c_types::derived::CVec_ChainHashZ +pub extern "C" fn COption_CVec_ChainHashZZ_some(o: crate::c_types::derived::CVec_ChainHashZ) -> COption_CVec_ChainHashZZ { + COption_CVec_ChainHashZZ::Some(o) } - #[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlockHashChannelMonitorZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_BlockHashChannelMonitorZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_BlockHashChannelMonitorZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Constructs a new COption_CVec_ChainHashZZ containing nothing +pub extern "C" fn COption_CVec_ChainHashZZ_none() -> COption_CVec_ChainHashZZ { + COption_CVec_ChainHashZZ::None } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res: CVec_C2Tuple_BlockHashChannelMonitorZZ) { } -impl Drop for CVec_C2Tuple_BlockHashChannelMonitorZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} +/// Frees any resources associated with the crate::c_types::derived::CVec_ChainHashZ, if we are in the Some state +pub extern "C" fn COption_CVec_ChainHashZZ_free(_res: COption_CVec_ChainHashZZ) { } +#[no_mangle] +/// Creates a new COption_CVec_ChainHashZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_CVec_ChainHashZZ_clone(orig: &COption_CVec_ChainHashZZ) -> COption_CVec_ChainHashZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ -pub union CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ +pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ, + pub result: *mut crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. +/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - /// The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either +pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { + /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr, - /// Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. + pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, + /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8654,13 +8844,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: cr } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o: &CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) { } -impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } +impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8673,16 +8863,16 @@ impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { } } } -impl From> for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } }; Self { contents, @@ -8690,79 +8880,59 @@ impl From bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> u16 { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_CounterpartyForwardingInfoDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_u16Z containing a u16 -pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { - COption_u16Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_u16Z containing nothing -pub extern "C" fn COption_u16Z_none() -> COption_u16Z { - COption_u16Z::None -} -#[no_mangle] -/// Frees any resources associated with the u16, if we are in the Some state -pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } -#[no_mangle] -/// Creates a new COption_u16Z which has the same data as `orig` +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult__u832APIErrorZ -pub union CResult__u832APIErrorZPtr { +/// The contents of CResult_ChannelCounterpartyDecodeErrorZ +pub union CResult_ChannelCounterpartyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::ln::channelmanager::ChannelCounterparty, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult__u832APIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult__u832APIErrorZ { - /// The contents of this CResult__u832APIErrorZ, accessible via either +pub struct CResult_ChannelCounterpartyDecodeErrorZ { + /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult__u832APIErrorZPtr, - /// Whether this CResult__u832APIErrorZ represents a success state. + pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, + /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ in the success state. -pub extern "C" fn CResult__u832APIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832APIErrorZ { - CResult__u832APIErrorZ { - contents: CResult__u832APIErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ in the error state. -pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult__u832APIErrorZ { - CResult__u832APIErrorZ { - contents: CResult__u832APIErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8770,13 +8940,13 @@ pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult__u832APIErrorZ_is_ok(o: &CResult__u832APIErrorZ) -> bool { +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult__u832APIErrorZ. -pub extern "C" fn CResult__u832APIErrorZ_free(_res: CResult__u832APIErrorZ) { } -impl Drop for CResult__u832APIErrorZ { +/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } +impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8789,16 +8959,16 @@ impl Drop for CResult__u832APIErrorZ { } } } -impl From> for CResult__u832APIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelCounterpartyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult__u832APIErrorZPtr { result } + CResult_ChannelCounterpartyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult__u832APIErrorZPtr { err } + CResult_ChannelCounterpartyDecodeErrorZPtr { err } }; Self { contents, @@ -8806,96 +8976,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult__u832APIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult__u832APIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult__u832APIErrorZ_clone(orig: &CResult__u832APIErrorZ) -> CResult__u832APIErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RecentPaymentDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RecentPaymentDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RecentPaymentDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } -impl Drop for CVec_RecentPaymentDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePaymentSendFailureZ -pub union CResult_NonePaymentSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ChannelDetailsDecodeErrorZ +pub union CResult_ChannelDetailsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::ChannelDetails, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentSendFailureZ { - /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either +pub struct CResult_ChannelDetailsDecodeErrorZ { + /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentSendFailureZPtr, - /// Whether this CResult_NonePaymentSendFailureZ represents a success state. + pub contents: CResult_ChannelDetailsDecodeErrorZPtr, + /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the success state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the error state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8903,15 +9036,18 @@ pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::o } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePaymentSendFailureZ. -pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } -impl Drop for CResult_NonePaymentSendFailureZ { +/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } +impl Drop for CResult_ChannelDetailsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8919,16 +9055,16 @@ impl Drop for CResult_NonePaymentSendFailureZ { } } } -impl From> for CResult_NonePaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { +impl From> for CResult_ChannelDetailsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePaymentSendFailureZPtr { err } + CResult_ChannelDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -8936,58 +9072,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneRetryableSendFailureZ -pub union CResult_NoneRetryableSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_PhantomRouteHintsDecodeErrorZ +pub union CResult_PhantomRouteHintsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneRetryableSendFailureZ { - /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either +pub struct CResult_PhantomRouteHintsDecodeErrorZ { + /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneRetryableSendFailureZPtr, - /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. + pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, + /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, - } -} +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8995,15 +9132,18 @@ pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } -impl Drop for CResult_NoneRetryableSendFailureZ { +/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } +impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -9011,16 +9151,16 @@ impl Drop for CResult_NoneRetryableSendFailureZ { } } } -impl From> for CResult_NoneRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { +impl From> for CResult_PhantomRouteHintsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PhantomRouteHintsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneRetryableSendFailureZPtr { err } + CResult_PhantomRouteHintsDecodeErrorZPtr { err } }; Self { contents, @@ -9028,59 +9168,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentHashPaymentSendFailureZ -pub union CResult_PaymentHashPaymentSendFailureZPtr { +/// The contents of CResult_ChannelShutdownStateDecodeErrorZ +pub union CResult_ChannelShutdownStateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::ln::channelmanager::ChannelShutdownState, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentHashPaymentSendFailureZ { - /// The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either +pub struct CResult_ChannelShutdownStateDecodeErrorZ { + /// The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentHashPaymentSendFailureZPtr, - /// Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. + pub contents: CResult_ChannelShutdownStateDecodeErrorZPtr, + /// Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashPaymentSendFailureZ { - CResult_PaymentHashPaymentSendFailureZ { - contents: CResult_PaymentHashPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_PaymentHashPaymentSendFailureZ { - CResult_PaymentHashPaymentSendFailureZ { - contents: CResult_PaymentHashPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9088,13 +9228,13 @@ pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_is_ok(o: &CResult_PaymentHashPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o: &CResult_ChannelShutdownStateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_free(_res: CResult_PaymentHashPaymentSendFailureZ) { } -impl Drop for CResult_PaymentHashPaymentSendFailureZ { +/// Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_free(_res: CResult_ChannelShutdownStateDecodeErrorZ) { } +impl Drop for CResult_ChannelShutdownStateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9107,16 +9247,16 @@ impl Drop for CResult_PaymentHashPaymentSendFailureZ { } } } -impl From> for CResult_PaymentHashPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelShutdownStateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentHashPaymentSendFailureZPtr { result } + CResult_ChannelShutdownStateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentHashPaymentSendFailureZPtr { err } + CResult_ChannelShutdownStateDecodeErrorZPtr { err } }; Self { contents, @@ -9124,59 +9264,127 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentHashPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentHashPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_clone(orig: &CResult_ChannelShutdownStateDecodeErrorZ) -> CResult_ChannelShutdownStateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentHashRetryableSendFailureZ -pub union CResult_PaymentHashRetryableSendFailureZPtr { +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelMonitorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChannelMonitorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ChannelMonitorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } +impl Drop for CVec_ChannelMonitorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelManagerZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::channelmanager::ChannelManager, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlockHashChannelManagerZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { + C2Tuple_BlockHashChannelManagerZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentHashRetryableSendFailureZ { - /// The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentHashRetryableSendFailureZPtr, - /// Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashRetryableSendFailureZ { - CResult_PaymentHashRetryableSendFailureZ { - contents: CResult_PaymentHashRetryableSendFailureZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_PaymentHashRetryableSendFailureZ { - CResult_PaymentHashRetryableSendFailureZ { - contents: CResult_PaymentHashRetryableSendFailureZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9184,13 +9392,13 @@ pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_is_ok(o: &CResult_PaymentHashRetryableSendFailureZ) -> bool { +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_free(_res: CResult_PaymentHashRetryableSendFailureZ) { } -impl Drop for CResult_PaymentHashRetryableSendFailureZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9203,16 +9411,16 @@ impl Drop for CResult_PaymentHashRetryableSendFailureZ { } } } -impl From> for CResult_PaymentHashRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentHashRetryableSendFailureZPtr { result } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentHashRetryableSendFailureZPtr { err } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } }; Self { contents, @@ -9220,101 +9428,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentHashRetryableSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PaymentHashRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_clone(orig: &CResult_PaymentHashRetryableSendFailureZ) -> CResult_PaymentHashRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PaymentHashPaymentIdZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, +/// The contents of CResult_MaxDustHTLCExposureDecodeErrorZ +pub union CResult_MaxDustHTLCExposureDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::config::MaxDustHTLCExposure, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentIdZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_MaxDustHTLCExposureDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::MaxDustHTLCExposure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_MaxDustHTLCExposureDecodeErrorZ { + /// The contents of this CResult_MaxDustHTLCExposureDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr, + /// Whether this CResult_MaxDustHTLCExposureDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_PaymentHashPaymentIdZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PaymentHashPaymentIdZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_clone(orig: &C2Tuple_PaymentHashPaymentIdZ) -> C2Tuple_PaymentHashPaymentIdZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentIdZ { - C2Tuple_PaymentHashPaymentIdZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_free(_res: C2Tuple_PaymentHashPaymentIdZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ -pub union CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, -} -#[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +#[no_mangle] +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the success state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o: crate::lightning::util::config::MaxDustHTLCExposure) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the error state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9322,13 +9471,13 @@ pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { +/// Frees any resources used by the CResult_MaxDustHTLCExposureDecodeErrorZ. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res: CResult_MaxDustHTLCExposureDecodeErrorZ) { } +impl Drop for CResult_MaxDustHTLCExposureDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9341,16 +9490,16 @@ impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_MaxDustHTLCExposureDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result } + CResult_MaxDustHTLCExposureDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { err } + CResult_MaxDustHTLCExposureDecodeErrorZPtr { err } }; Self { contents, @@ -9358,179 +9507,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ThirtyTwoBytesZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ThirtyTwoBytesZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ThirtyTwoBytesZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } -impl Drop for CVec_ThirtyTwoBytesZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ThirtyTwoBytesZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PaymentHashPaymentSecretZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentSecretZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_PaymentHashPaymentSecretZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PaymentHashPaymentSecretZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ { - C2Tuple_PaymentHashPaymentSecretZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_free(_res: C2Tuple_PaymentHashPaymentSecretZ) { } +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> CResult_MaxDustHTLCExposureDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ -pub union CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +/// The contents of CResult_ChannelConfigDecodeErrorZ +pub union CResult_ChannelConfigDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::util::config::ChannelConfig, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. +/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either +pub struct CResult_ChannelConfigDecodeErrorZ { + /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. + pub contents: CResult_ChannelConfigDecodeErrorZPtr, + /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> bool { +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } +impl Drop for CResult_ChannelConfigDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelConfigDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result } + CResult_ChannelConfigDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelConfigDecodeErrorZPtr { err } }; Self { contents, @@ -9538,59 +9603,133 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ -pub union CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, -} +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a crate::lightning::util::errors::APIError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::config::MaxDustHTLCExposure or not +pub enum COption_MaxDustHTLCExposureZ { + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains a crate::lightning::util::config::MaxDustHTLCExposure + Some(crate::lightning::util::config::MaxDustHTLCExposure), + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_MaxDustHTLCExposureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::config::MaxDustHTLCExposure { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing a crate::lightning::util::config::MaxDustHTLCExposure +pub extern "C" fn COption_MaxDustHTLCExposureZ_some(o: crate::lightning::util::config::MaxDustHTLCExposure) -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing nothing +pub extern "C" fn COption_MaxDustHTLCExposureZ_none() -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::config::MaxDustHTLCExposure, if we are in the Some state +pub extern "C" fn COption_MaxDustHTLCExposureZ_free(_res: COption_MaxDustHTLCExposureZ) { } +#[no_mangle] +/// Creates a new COption_MaxDustHTLCExposureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MaxDustHTLCExposureZ_clone(orig: &COption_MaxDustHTLCExposureZ) -> COption_MaxDustHTLCExposureZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::errors::APIError or not +pub enum COption_APIErrorZ { + /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError + Some(crate::lightning::util::errors::APIError), + /// When we're in this state, this COption_APIErrorZ contains nothing + None +} +impl COption_APIErrorZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError +pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { + COption_APIErrorZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing nothing +pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { + COption_APIErrorZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state +pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } +#[no_mangle] +/// Creates a new COption_APIErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_APIErrorZDecodeErrorZ +pub union CResult_COption_APIErrorZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_APIErrorZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_APIErrorZDecodeErrorZ { + /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, + /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9598,13 +9737,13 @@ pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e: crat } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) -> bool { +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { +/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } +impl Drop for CResult_COption_APIErrorZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9617,16 +9756,16 @@ impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_APIErrorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { result } + CResult_COption_APIErrorZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { err } + CResult_COption_APIErrorZDecodeErrorZPtr { err } }; Self { contents, @@ -9634,91 +9773,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentSecretNoneZ -pub union CResult_PaymentSecretNoneZPtr { +/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ +pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentSecretNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. +/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentSecretNoneZ { - /// The contents of this CResult_PaymentSecretNoneZ, accessible via either +pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentSecretNoneZPtr, - /// Whether this CResult_PaymentSecretNoneZ represents a success state. + pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ in the success state. -pub extern "C" fn CResult_PaymentSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretNoneZ { - CResult_PaymentSecretNoneZ { - contents: CResult_PaymentSecretNoneZPtr { +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ in the error state. -pub extern "C" fn CResult_PaymentSecretNoneZ_err() -> CResult_PaymentSecretNoneZ { - CResult_PaymentSecretNoneZ { - contents: CResult_PaymentSecretNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentSecretNoneZ_is_ok(o: &CResult_PaymentSecretNoneZ) -> bool { +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentSecretNoneZ. -pub extern "C" fn CResult_PaymentSecretNoneZ_free(_res: CResult_PaymentSecretNoneZ) { } -impl Drop for CResult_PaymentSecretNoneZ { +/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_PaymentSecretNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentSecretNoneZPtr { result } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -9726,59 +9869,96 @@ impl From> for } } } -impl Clone for CResult_PaymentSecretNoneZ { +impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentSecretNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentSecretNoneZ_clone(orig: &CResult_PaymentSecretNoneZ) -> CResult_PaymentSecretNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not +pub enum COption_MonitorEventZ { + /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent + Some(crate::lightning::chain::channelmonitor::MonitorEvent), + /// When we're in this state, this COption_MonitorEventZ contains nothing + None +} +impl COption_MonitorEventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent +pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { + COption_MonitorEventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing nothing +pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { + COption_MonitorEventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state +pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } +#[no_mangle] +/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentSecretAPIErrorZ -pub union CResult_PaymentSecretAPIErrorZPtr { +/// The contents of CResult_COption_MonitorEventZDecodeErrorZ +pub union CResult_COption_MonitorEventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::COption_MonitorEventZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentSecretAPIErrorZ { - /// The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either +pub struct CResult_COption_MonitorEventZDecodeErrorZ { + /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentSecretAPIErrorZPtr, - /// Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, + /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ in the success state. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretAPIErrorZ { - CResult_PaymentSecretAPIErrorZ { - contents: CResult_PaymentSecretAPIErrorZPtr { +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ in the error state. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentSecretAPIErrorZ { - CResult_PaymentSecretAPIErrorZ { - contents: CResult_PaymentSecretAPIErrorZPtr { +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9786,13 +9966,13 @@ pub extern "C" fn CResult_PaymentSecretAPIErrorZ_err(e: crate::lightning::util:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_is_ok(o: &CResult_PaymentSecretAPIErrorZ) -> bool { +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentSecretAPIErrorZ. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_free(_res: CResult_PaymentSecretAPIErrorZ) { } -impl Drop for CResult_PaymentSecretAPIErrorZ { +/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } +impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9805,16 +9985,16 @@ impl Drop for CResult_PaymentSecretAPIErrorZ { } } } -impl From> for CResult_PaymentSecretAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_MonitorEventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentSecretAPIErrorZPtr { result } + CResult_COption_MonitorEventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentSecretAPIErrorZPtr { err } + CResult_COption_MonitorEventZDecodeErrorZPtr { err } }; Self { contents, @@ -9822,59 +10002,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentSecretAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentSecretAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_clone(orig: &CResult_PaymentSecretAPIErrorZ) -> CResult_PaymentSecretAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPreimageAPIErrorZ -pub union CResult_PaymentPreimageAPIErrorZPtr { +/// The contents of CResult_HTLCUpdateDecodeErrorZ +pub union CResult_HTLCUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentPreimageAPIErrorZ { - /// The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either +pub struct CResult_HTLCUpdateDecodeErrorZ { + /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentPreimageAPIErrorZPtr, - /// Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. + pub contents: CResult_HTLCUpdateDecodeErrorZPtr, + /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentPreimageAPIErrorZ { - CResult_PaymentPreimageAPIErrorZ { - contents: CResult_PaymentPreimageAPIErrorZPtr { +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentPreimageAPIErrorZ { - CResult_PaymentPreimageAPIErrorZ { - contents: CResult_PaymentPreimageAPIErrorZPtr { +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9882,13 +10062,13 @@ pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_is_ok(o: &CResult_PaymentPreimageAPIErrorZ) -> bool { +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_free(_res: CResult_PaymentPreimageAPIErrorZ) { } -impl Drop for CResult_PaymentPreimageAPIErrorZ { +/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } +impl Drop for CResult_HTLCUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9901,16 +10081,16 @@ impl Drop for CResult_PaymentPreimageAPIErrorZ { } } } -impl From> for CResult_PaymentPreimageAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPreimageAPIErrorZPtr { result } + CResult_HTLCUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPreimageAPIErrorZPtr { err } + CResult_HTLCUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -9918,431 +10098,353 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentPreimageAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPreimageAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_clone(orig: &CResult_PaymentPreimageAPIErrorZ) -> CResult_PaymentPreimageAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ -pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointScriptZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, } -#[repr(C)] -/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { - /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, - /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } } -#[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl C2Tuple_OutPointScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) } } -#[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl Clone for C2Tuple_OutPointScriptZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { - o.result_ok +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { + C2Tuple_OutPointScriptZ { a, b, } } + #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } -impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources used by the C2Tuple_OutPointScriptZ. +pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32ScriptZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, } -impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } - }; +impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { + fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_CounterpartyForwardingInfoDecodeErrorZ { +impl C2Tuple_u32ScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32ScriptZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelCounterpartyDecodeErrorZ -pub union CResult_ChannelCounterpartyDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelCounterparty, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32ScriptZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { + C2Tuple_u32ScriptZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32ScriptZ. +pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } #[repr(C)] -/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelCounterpartyDecodeErrorZ { - /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, - /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_u32ScriptZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_u32ScriptZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_u32ScriptZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } -impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } +impl Drop for CVec_C2Tuple_u32ScriptZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_ChannelCounterpartyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelCounterpartyDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelCounterpartyDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_u32ScriptZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_ChannelCounterpartyDecodeErrorZ { +impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelDetailsDecodeErrorZ -pub union CResult_ChannelDetailsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } #[repr(C)] -/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelDetailsDecodeErrorZ { - /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelDetailsDecodeErrorZPtr, - /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } -impl Drop for CResult_ChannelDetailsDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } +impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelDetailsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelDetailsDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelDetailsDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelDetailsDecodeErrorZ { +impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PhantomRouteHintsDecodeErrorZ -pub union CResult_PhantomRouteHintsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Transaction, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PhantomRouteHintsDecodeErrorZ { - /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, - /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. - pub result_ok: bool, +impl CVec_TransactionZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } } -#[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl From> for CVec_TransactionZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } +impl Drop for CVec_TransactionZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } -impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } +impl Clone for CVec_TransactionZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -impl From> for CResult_PhantomRouteHintsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PhantomRouteHintsDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PhantomRouteHintsDecodeErrorZPtr { err } - }; +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32TxOutZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::TxOut, +} +impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { + fn from (tup: (u32, crate::c_types::TxOut)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_PhantomRouteHintsDecodeErrorZ { +impl C2Tuple_u32TxOutZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32TxOutZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32TxOutZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { + C2Tuple_u32TxOutZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32TxOutZ. +pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_ChannelMonitorZ { +pub struct CVec_C2Tuple_u32TxOutZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_ChannelMonitorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_u32TxOutZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_ChannelMonitorZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_u32TxOutZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -10350,158 +10452,221 @@ impl From> for CVec } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } -impl Drop for CVec_ChannelMonitorZ { +pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } +impl Drop for CVec_C2Tuple_u32TxOutZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } +impl Clone for CVec_C2Tuple_u32TxOutZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelManagerZ { +pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /// The element at position 0 pub a: crate::c_types::ThirtyTwoBytes, /// The element at position 1 - pub b: crate::lightning::ln::channelmanager::ChannelManager, + pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_BlockHashChannelManagerZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { +impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { (self.a, self.b) } } -/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. +impl Clone for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} #[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { - C2Tuple_BlockHashChannelManagerZ { a, b, } +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionOutputsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_TransactionOutputsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_TransactionOutputsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } +impl Drop for CVec_TransactionOutputsZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_TransactionOutputsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_ChannelConfigDecodeErrorZ -pub union CResult_ChannelConfigDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BalanceZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::Balance, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BalanceZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BalanceZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } +impl Drop for CVec_BalanceZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_BalanceZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelMonitorZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlockHashChannelMonitorZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { + C2Tuple_BlockHashChannelMonitorZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::config::ChannelConfig, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelConfigDecodeErrorZ { - /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelConfigDecodeErrorZPtr, - /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10509,13 +10674,13 @@ pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } -impl Drop for CResult_ChannelConfigDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10528,16 +10693,16 @@ impl Drop for CResult_ChannelConfigDecodeErrorZ { } } } -impl From> for CResult_ChannelConfigDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelConfigDecodeErrorZPtr { result } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelConfigDecodeErrorZPtr { err } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } }; Self { contents, @@ -10545,288 +10710,179 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PublicKeyTypeZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::lightning::ln::wire::Type, +} +impl From<(crate::c_types::PublicKey, crate::lightning::ln::wire::Type)> for C2Tuple_PublicKeyTypeZ { + fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } +impl C2Tuple_PublicKeyTypeZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { + C2Tuple_PublicKeyTypeZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. +pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_PublicKeyTypeZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_PublicKeyTypeZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_PublicKeyTypeZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } +impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::errors::APIError or not -pub enum COption_APIErrorZ { - /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError - Some(crate::lightning::util::errors::APIError), - /// When we're in this state, this COption_APIErrorZ contains nothing +/// An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not +pub enum COption_OffersMessageZ { + /// When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage + Some(crate::lightning::onion_message::offers::OffersMessage), + /// When we're in this state, this COption_OffersMessageZ contains nothing None } -impl COption_APIErrorZ { +impl COption_OffersMessageZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::offers::OffersMessage { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError -pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { - COption_APIErrorZ::Some(o) +/// Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage +pub extern "C" fn COption_OffersMessageZ_some(o: crate::lightning::onion_message::offers::OffersMessage) -> COption_OffersMessageZ { + COption_OffersMessageZ::Some(o) } #[no_mangle] -/// Constructs a new COption_APIErrorZ containing nothing -pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { - COption_APIErrorZ::None +/// Constructs a new COption_OffersMessageZ containing nothing +pub extern "C" fn COption_OffersMessageZ_none() -> COption_OffersMessageZ { + COption_OffersMessageZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state -pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } +/// Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state +pub extern "C" fn COption_OffersMessageZ_free(_res: COption_OffersMessageZ) { } #[no_mangle] -/// Creates a new COption_APIErrorZ which has the same data as `orig` +/// Creates a new COption_OffersMessageZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_OffersMessageZ_clone(orig: &COption_OffersMessageZ) -> COption_OffersMessageZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_APIErrorZDecodeErrorZ -pub union CResult_COption_APIErrorZDecodeErrorZPtr { +/// An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not +pub enum COption_CustomOnionMessageContentsZ { + /// When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents + Some(crate::lightning::onion_message::packet::CustomOnionMessageContents), + /// When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing + None +} +impl COption_CustomOnionMessageContentsZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::CustomOnionMessageContents { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents +pub extern "C" fn COption_CustomOnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> COption_CustomOnionMessageContentsZ { + COption_CustomOnionMessageContentsZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_CustomOnionMessageContentsZ containing nothing +pub extern "C" fn COption_CustomOnionMessageContentsZ_none() -> COption_CustomOnionMessageContentsZ { + COption_CustomOnionMessageContentsZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state +pub extern "C" fn COption_CustomOnionMessageContentsZ_free(_res: COption_CustomOnionMessageContentsZ) { } +#[repr(C)] +/// The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ +pub union CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_APIErrorZ, + pub result: *mut crate::c_types::derived::COption_CustomOnionMessageContentsZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_APIErrorZDecodeErrorZ { - /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, - /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } -impl Drop for CResult_COption_APIErrorZDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_COption_APIErrorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_APIErrorZDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_APIErrorZDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_COption_APIErrorZDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_UntrustedStringDecodeErrorZ -pub union CResult_UntrustedStringDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::string::UntrustedString, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UntrustedStringDecodeErrorZ { - /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UntrustedStringDecodeErrorZPtr, - /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } -impl Drop for CResult_UntrustedStringDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_UntrustedStringDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UntrustedStringDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UntrustedStringDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_UntrustedStringDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_OutPointDecodeErrorZ -pub union CResult_OutPointDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::transaction::OutPoint, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OutPointDecodeErrorZ { - /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either +pub struct CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + /// The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutPointDecodeErrorZPtr, - /// Whether this CResult_OutPointDecodeErrorZ represents a success state. + pub contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr, + /// Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_CustomOnionMessageContentsZ) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10834,13 +10890,13 @@ pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OutPointDecodeErrorZ. -pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } -impl Drop for CResult_OutPointDecodeErrorZ { +/// Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) { } +impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10853,16 +10909,16 @@ impl Drop for CResult_OutPointDecodeErrorZ { } } } -impl From> for CResult_OutPointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OutPointDecodeErrorZPtr { result } + CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutPointDecodeErrorZPtr { err } + CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err } }; Self { contents, @@ -10870,23 +10926,6 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// An enum which can either contain a crate::lightning::ln::wire::Type or not pub enum COption_TypeZ { @@ -10999,41 +11038,166 @@ impl From bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::NetAddress { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress +pub extern "C" fn COption_NetAddressZ_some(o: crate::lightning::ln::msgs::NetAddress) -> COption_NetAddressZ { + COption_NetAddressZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_NetAddressZ containing nothing +pub extern "C" fn COption_NetAddressZ_none() -> COption_NetAddressZ { + COption_NetAddressZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state +pub extern "C" fn COption_NetAddressZ_free(_res: COption_NetAddressZ) { } +#[no_mangle] +/// Creates a new COption_NetAddressZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetAddressZ_clone(orig: &COption_NetAddressZ) -> COption_NetAddressZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PublicKeyCOption_NetAddressZZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::c_types::derived::COption_NetAddressZ, +} +impl From<(crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)> for C2Tuple_PublicKeyCOption_NetAddressZZ { + fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PublicKeyCOption_NetAddressZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PublicKeyCOption_NetAddressZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig: &C2Tuple_PublicKeyCOption_NetAddressZZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::COption_NetAddressZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { + C2Tuple_PublicKeyCOption_NetAddressZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res: C2Tuple_PublicKeyCOption_NetAddressZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ) { } +impl Drop for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_u8ZPeerHandleErrorZ +pub union CResult_CVec_u8ZPeerHandleErrorZPtr { + /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::CVec_u8Z, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::payment::PaymentError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. +/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentIdPaymentErrorZ { - /// The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either +pub struct CResult_CVec_u8ZPeerHandleErrorZ { + /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentIdPaymentErrorZPtr, - /// Whether this CResult_PaymentIdPaymentErrorZ represents a success state. + pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, + /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ in the success state. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentIdPaymentErrorZ { - CResult_PaymentIdPaymentErrorZ { - contents: CResult_PaymentIdPaymentErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ in the error state. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_PaymentIdPaymentErrorZ { - CResult_PaymentIdPaymentErrorZ { - contents: CResult_PaymentIdPaymentErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11041,13 +11205,13 @@ pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_is_ok(o: &CResult_PaymentIdPaymentErrorZ) -> bool { +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentIdPaymentErrorZ. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_free(_res: CResult_PaymentIdPaymentErrorZ) { } -impl Drop for CResult_PaymentIdPaymentErrorZ { +/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } +impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11060,16 +11224,16 @@ impl Drop for CResult_PaymentIdPaymentErrorZ { } } } -impl From> for CResult_PaymentIdPaymentErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_u8ZPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentIdPaymentErrorZPtr { result } + CResult_CVec_u8ZPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentIdPaymentErrorZPtr { err } + CResult_CVec_u8ZPeerHandleErrorZPtr { err } }; Self { contents, @@ -11077,58 +11241,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentIdPaymentErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentIdPaymentErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_clone(orig: &CResult_PaymentIdPaymentErrorZ) -> CResult_PaymentIdPaymentErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePaymentErrorZ -pub union CResult_NonePaymentErrorZPtr { +/// The contents of CResult_NonePeerHandleErrorZ +pub union CResult_NonePeerHandleErrorZPtr { /// Note that this value is always NULL, as there are no contents in the OK variant pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::payment::PaymentError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_NonePaymentErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. +/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentErrorZ { - /// The contents of this CResult_NonePaymentErrorZ, accessible via either +pub struct CResult_NonePeerHandleErrorZ { + /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentErrorZPtr, - /// Whether this CResult_NonePaymentErrorZ represents a success state. + pub contents: CResult_NonePeerHandleErrorZPtr, + /// Whether this CResult_NonePeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ in the success state. -pub extern "C" fn CResult_NonePaymentErrorZ_ok() -> CResult_NonePaymentErrorZ { - CResult_NonePaymentErrorZ { - contents: CResult_NonePaymentErrorZPtr { +/// Creates a new CResult_NonePeerHandleErrorZ in the success state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ in the error state. -pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_NonePaymentErrorZ { - CResult_NonePaymentErrorZ { - contents: CResult_NonePaymentErrorZPtr { +/// Creates a new CResult_NonePeerHandleErrorZ in the error state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11136,13 +11300,13 @@ pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::pay } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePaymentErrorZ_is_ok(o: &CResult_NonePaymentErrorZ) -> bool { +pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePaymentErrorZ. -pub extern "C" fn CResult_NonePaymentErrorZ_free(_res: CResult_NonePaymentErrorZ) { } -impl Drop for CResult_NonePaymentErrorZ { +/// Frees any resources used by the CResult_NonePeerHandleErrorZ. +pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } +impl Drop for CResult_NonePeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { } else { @@ -11152,16 +11316,16 @@ impl Drop for CResult_NonePaymentErrorZ { } } } -impl From> for CResult_NonePaymentErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::payment::PaymentError>) -> Self { +impl From> for CResult_NonePeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { let contents = if o.result_ok { let _ = unsafe { Box::from_raw(o.contents.result) }; o.contents.result = core::ptr::null_mut(); - CResult_NonePaymentErrorZPtr { result: core::ptr::null_mut() } + CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePaymentErrorZPtr { err } + CResult_NonePeerHandleErrorZPtr { err } }; Self { contents, @@ -11169,59 +11333,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentErrorZPtr { + Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_NonePaymentErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentErrorZ_clone(orig: &CResult_NonePaymentErrorZ) -> CResult_NonePaymentErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StringErrorZ -pub union CResult_StringErrorZPtr { +/// The contents of CResult_boolPeerHandleErrorZ +pub union CResult_boolPeerHandleErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Str, + pub result: *mut bool, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_StringErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StringErrorZ { - /// The contents of this CResult_StringErrorZ, accessible via either +pub struct CResult_boolPeerHandleErrorZ { + /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StringErrorZPtr, - /// Whether this CResult_StringErrorZ represents a success state. + pub contents: CResult_boolPeerHandleErrorZPtr, + /// Whether this CResult_boolPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StringErrorZ in the success state. -pub extern "C" fn CResult_StringErrorZ_ok(o: crate::c_types::Str) -> CResult_StringErrorZ { - CResult_StringErrorZ { - contents: CResult_StringErrorZPtr { +/// Creates a new CResult_boolPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StringErrorZ in the error state. -pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StringErrorZ { - CResult_StringErrorZ { - contents: CResult_StringErrorZPtr { +/// Creates a new CResult_boolPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11229,13 +11393,13 @@ pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StringErrorZ_is_ok(o: &CResult_StringErrorZ) -> bool { +pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StringErrorZ. -pub extern "C" fn CResult_StringErrorZ_free(_res: CResult_StringErrorZ) { } -impl Drop for CResult_StringErrorZ { +/// Frees any resources used by the CResult_boolPeerHandleErrorZ. +pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } +impl Drop for CResult_boolPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11248,16 +11412,16 @@ impl Drop for CResult_StringErrorZ { } } } -impl From> for CResult_StringErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_boolPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StringErrorZPtr { result } + CResult_boolPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StringErrorZPtr { err } + CResult_boolPeerHandleErrorZPtr { err } }; Self { contents, @@ -11265,59 +11429,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StringErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StringErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_StringErrorZ which has the same data as `orig` +/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ -pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// The contents of CResult_u32GraphSyncErrorZ +pub union CResult_u32GraphSyncErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, + pub result: *mut u32, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, } #[repr(C)] -/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, +/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either +pub struct CResult_u32GraphSyncErrorZ { + /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + pub contents: CResult_u32GraphSyncErrorZPtr, + /// Whether this CResult_u32GraphSyncErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_u32GraphSyncErrorZ in the success state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_u32GraphSyncErrorZ in the error state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11325,13 +11489,13 @@ pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_u32GraphSyncErrorZ. +pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } +impl Drop for CResult_u32GraphSyncErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11344,16 +11508,16 @@ impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_u32GraphSyncErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } + CResult_u32GraphSyncErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } + CResult_u32GraphSyncErrorZPtr { err } }; Self { contents, @@ -11361,132 +11525,111 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not -pub enum COption_MonitorEventZ { - /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent - Some(crate::lightning::chain::channelmonitor::MonitorEvent), - /// When we're in this state, this COption_MonitorEventZ contains nothing +/// An enum which can either contain a crate::c_types::SecretKey or not +pub enum COption_KeyPairZ { + /// When we're in this state, this COption_KeyPairZ contains a crate::c_types::SecretKey + Some(crate::c_types::SecretKey), + /// When we're in this state, this COption_KeyPairZ contains nothing None } -impl COption_MonitorEventZ { +impl COption_KeyPairZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::SecretKey { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent -pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { - COption_MonitorEventZ::Some(o) +/// Constructs a new COption_KeyPairZ containing a crate::c_types::SecretKey +pub extern "C" fn COption_KeyPairZ_some(o: crate::c_types::SecretKey) -> COption_KeyPairZ { + COption_KeyPairZ::Some(o) } #[no_mangle] -/// Constructs a new COption_MonitorEventZ containing nothing -pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { - COption_MonitorEventZ::None +/// Constructs a new COption_KeyPairZ containing nothing +pub extern "C" fn COption_KeyPairZ_none() -> COption_KeyPairZ { + COption_KeyPairZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state -pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } +/// Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state +pub extern "C" fn COption_KeyPairZ_free(_res: COption_KeyPairZ) { } #[no_mangle] -/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// Creates a new COption_KeyPairZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } +pub extern "C" fn COption_KeyPairZ_clone(orig: &COption_KeyPairZ) -> COption_KeyPairZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_MonitorEventZDecodeErrorZ -pub union CResult_COption_MonitorEventZDecodeErrorZPtr { +/// The contents of CResult_COption_KeyPairZNoneZ +pub union CResult_COption_KeyPairZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_MonitorEventZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::COption_KeyPairZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_KeyPairZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_KeyPairZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_MonitorEventZDecodeErrorZ { - /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either +pub struct CResult_COption_KeyPairZNoneZ { + /// The contents of this CResult_COption_KeyPairZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, - /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + pub contents: CResult_COption_KeyPairZNoneZPtr, + /// Whether this CResult_COption_KeyPairZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { +/// Creates a new CResult_COption_KeyPairZNoneZ in the success state. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_ok(o: crate::c_types::derived::COption_KeyPairZ) -> CResult_COption_KeyPairZNoneZ { + CResult_COption_KeyPairZNoneZ { + contents: CResult_COption_KeyPairZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_COption_KeyPairZNoneZ in the error state. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_err() -> CResult_COption_KeyPairZNoneZ { + CResult_COption_KeyPairZNoneZ { + contents: CResult_COption_KeyPairZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_KeyPairZNoneZ_is_ok(o: &CResult_COption_KeyPairZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } -impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { +/// Frees any resources used by the CResult_COption_KeyPairZNoneZ. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_free(_res: CResult_COption_KeyPairZNoneZ) { } +impl Drop for CResult_COption_KeyPairZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_COption_MonitorEventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_KeyPairZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_MonitorEventZDecodeErrorZPtr { result } + CResult_COption_KeyPairZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_MonitorEventZDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_COption_KeyPairZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -11494,227 +11637,113 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_KeyPairZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_KeyPairZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_KeyPairZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_HTLCUpdateDecodeErrorZ -pub union CResult_HTLCUpdateDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_COption_KeyPairZNoneZ_clone(orig: &CResult_COption_KeyPairZNoneZ) -> CResult_COption_KeyPairZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCUpdateDecodeErrorZ { - /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCUpdateDecodeErrorZPtr, - /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::CVec_u8Z or not +pub enum COption_ScriptZ { + /// When we're in this state, this COption_ScriptZ contains a crate::c_types::derived::CVec_u8Z + Some(crate::c_types::derived::CVec_u8Z), + /// When we're in this state, this COption_ScriptZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_ScriptZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_u8Z { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_ScriptZ containing a crate::c_types::derived::CVec_u8Z +pub extern "C" fn COption_ScriptZ_some(o: crate::c_types::derived::CVec_u8Z) -> COption_ScriptZ { + COption_ScriptZ::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_ScriptZ containing nothing +pub extern "C" fn COption_ScriptZ_none() -> COption_ScriptZ { + COption_ScriptZ::None } #[no_mangle] -/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } -impl Drop for CResult_HTLCUpdateDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_HTLCUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCUpdateDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCUpdateDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_HTLCUpdateDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} +/// Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state +pub extern "C" fn COption_ScriptZ_free(_res: COption_ScriptZ) { } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new COption_ScriptZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_ScriptZ_clone(orig: &COption_ScriptZ) -> COption_ScriptZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_OutPointScriptZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +/// An enum which can either contain a or not +pub enum COption_NoneZ { + /// When we're in this state, this COption_NoneZ contains a + Some, + /// When we're in this state, this COption_NoneZ contains nothing + None } -impl C2Tuple_OutPointScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) +impl COption_NoneZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl Clone for C2Tuple_OutPointScriptZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { - C2Tuple_OutPointScriptZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointScriptZ. -pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32ScriptZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { - fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u32ScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32ScriptZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } +/// Constructs a new COption_NoneZ containing a +pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { + COption_NoneZ::Some } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32ScriptZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { - C2Tuple_u32ScriptZ { a, b, } +/// Constructs a new COption_NoneZ containing nothing +pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { + COption_NoneZ::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_u32ScriptZ. -pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } +/// Frees any resources associated with the , if we are in the Some state +pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32ScriptZZ { +pub struct CVec_WitnessZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + pub data: *mut crate::c_types::Witness, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32ScriptZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_WitnessZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Witness] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32ScriptZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_WitnessZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11722,14 +11751,14 @@ impl From> for CVec_C2Tuple_u32 } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } -impl Drop for CVec_C2Tuple_u32ScriptZZ { +pub extern "C" fn CVec_WitnessZ_free(_res: CVec_WitnessZ) { } +impl Drop for CVec_WitnessZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32ScriptZZ { +impl Clone for CVec_WitnessZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11738,163 +11767,199 @@ impl Clone for CVec_C2Tuple_u32ScriptZZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +#[derive(Clone)] +/// An enum which can either contain a i64 or not +pub enum COption_i64Z { + /// When we're in this state, this COption_i64Z contains a i64 + Some(i64), + /// When we're in this state, this COption_i64Z contains nothing + None } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_i64Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl Clone for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn take(mut self) -> i64 { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. +/// Constructs a new COption_i64Z containing a i64 +pub extern "C" fn COption_i64Z_some(o: i64) -> COption_i64Z { + COption_i64Z::Some(o) +} #[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } +/// Constructs a new COption_i64Z containing nothing +pub extern "C" fn COption_i64Z_none() -> COption_i64Z { + COption_i64Z::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } +/// Frees any resources associated with the i64, if we are in the Some state +pub extern "C" fn COption_i64Z_free(_res: COption_i64Z) { } +#[no_mangle] +/// Creates a new COption_i64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_i64Z_clone(orig: &COption_i64Z) -> COption_i64Z { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_TxidZ { + /// When we're in this state, this COption_TxidZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_TxidZ contains nothing + None } -impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_TxidZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } -impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +/// Constructs a new COption_TxidZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_TxidZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_TxidZ { + COption_TxidZ::Some(o) } -impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +#[no_mangle] +/// Constructs a new COption_TxidZ containing nothing +pub extern "C" fn COption_TxidZ_none() -> COption_TxidZ { + COption_TxidZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_TxidZ_free(_res: COption_TxidZ) { } +#[no_mangle] +/// Creates a new COption_TxidZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_TxidZ_clone(orig: &COption_TxidZ) -> COption_TxidZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::Events of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_EventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::Event, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_EventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::Event] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// The contents of CResult_NetAddressDecodeErrorZ +pub union CResult_NetAddressDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::NetAddress, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From> for CVec_EventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[repr(C)] +/// A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NetAddressDecodeErrorZ { + /// The contents of this CResult_NetAddressDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NetAddressDecodeErrorZPtr, + /// Whether this CResult_NetAddressDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NetAddressDecodeErrorZ in the success state. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressDecodeErrorZ { + CResult_NetAddressDecodeErrorZ { + contents: CResult_NetAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_EventZ_free(_res: CVec_EventZ) { } -impl Drop for CVec_EventZ { +/// Creates a new CResult_NetAddressDecodeErrorZ in the error state. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetAddressDecodeErrorZ { + CResult_NetAddressDecodeErrorZ { + contents: CResult_NetAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NetAddressDecodeErrorZ_is_ok(o: &CResult_NetAddressDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NetAddressDecodeErrorZ. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_free(_res: CResult_NetAddressDecodeErrorZ) { } +impl Drop for CResult_NetAddressDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NetAddressDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NetAddressDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NetAddressDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_EventZ { +impl Clone for CResult_NetAddressDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_NetAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NetAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TransactionZ { +pub struct CVec_UpdateAddHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Transaction, + pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TransactionZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateAddHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_TransactionZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateAddHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11902,14 +11967,14 @@ impl From> for CVec_TransactionZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } -impl Drop for CVec_TransactionZ { +pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } +impl Drop for CVec_UpdateAddHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_TransactionZ { +impl Clone for CVec_UpdateAddHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11918,71 +11983,29 @@ impl Clone for CVec_TransactionZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32TxOutZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::TxOut, -} -impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { - fn from (tup: (u32, crate::c_types::TxOut)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u32TxOutZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32TxOutZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32TxOutZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { - C2Tuple_u32TxOutZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u32TxOutZ. -pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32TxOutZZ { +pub struct CVec_UpdateFulfillHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, + pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32TxOutZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFulfillHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32TxOutZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFulfillHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11990,14 +12013,14 @@ impl From> for CVec_C2Tuple_u32T } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } -impl Drop for CVec_C2Tuple_u32TxOutZZ { +pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } +impl Drop for CVec_UpdateFulfillHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32TxOutZZ { +impl Clone for CVec_UpdateFulfillHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -12006,71 +12029,29 @@ impl Clone for CVec_C2Tuple_u32TxOutZZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TransactionOutputsZ { +pub struct CVec_UpdateFailHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, + pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TransactionOutputsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFailHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_TransactionOutputsZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFailHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -12078,14 +12059,14 @@ impl From> fo } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } -impl Drop for CVec_TransactionOutputsZ { +pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } +impl Drop for CVec_UpdateFailHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_TransactionOutputsZ { +impl Clone for CVec_UpdateFailHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -12094,87 +12075,3447 @@ impl Clone for CVec_TransactionOutputsZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BalanceZ { +pub struct CVec_UpdateFailMalformedHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::Balance, + pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BalanceZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFailMalformedHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BalanceZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFailMalformedHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } -impl Drop for CVec_BalanceZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } +impl Drop for CVec_UpdateFailMalformedHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateFailMalformedHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_AcceptChannelDecodeErrorZ +pub union CResult_AcceptChannelDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannel, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelDecodeErrorZ { + /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelDecodeErrorZPtr, + /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } +impl Drop for CResult_AcceptChannelDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_AcceptChannelV2DecodeErrorZ +pub union CResult_AcceptChannelV2DecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelV2DecodeErrorZ { + /// The contents of this CResult_AcceptChannelV2DecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelV2DecodeErrorZPtr, + /// Whether this CResult_AcceptChannelV2DecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannelV2) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_is_ok(o: &CResult_AcceptChannelV2DecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelV2DecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_free(_res: CResult_AcceptChannelV2DecodeErrorZ) { } +impl Drop for CResult_AcceptChannelV2DecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelV2DecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelV2DecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelV2DecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_clone(orig: &CResult_AcceptChannelV2DecodeErrorZ) -> CResult_AcceptChannelV2DecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddInputDecodeErrorZ +pub union CResult_TxAddInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddInputDecodeErrorZ { + /// The contents of this CResult_TxAddInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddInputDecodeErrorZPtr, + /// Whether this CResult_TxAddInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddInput) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_is_ok(o: &CResult_TxAddInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddInputDecodeErrorZ. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_free(_res: CResult_TxAddInputDecodeErrorZ) { } +impl Drop for CResult_TxAddInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_clone(orig: &CResult_TxAddInputDecodeErrorZ) -> CResult_TxAddInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddOutputDecodeErrorZ +pub union CResult_TxAddOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddOutputDecodeErrorZ { + /// The contents of this CResult_TxAddOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddOutputDecodeErrorZPtr, + /// Whether this CResult_TxAddOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddOutput) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_is_ok(o: &CResult_TxAddOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddOutputDecodeErrorZ. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_free(_res: CResult_TxAddOutputDecodeErrorZ) { } +impl Drop for CResult_TxAddOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_clone(orig: &CResult_TxAddOutputDecodeErrorZ) -> CResult_TxAddOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveInputDecodeErrorZ +pub union CResult_TxRemoveInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveInputDecodeErrorZ { + /// The contents of this CResult_TxRemoveInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveInputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveInput) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_is_ok(o: &CResult_TxRemoveInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveInputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_free(_res: CResult_TxRemoveInputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_clone(orig: &CResult_TxRemoveInputDecodeErrorZ) -> CResult_TxRemoveInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveOutputDecodeErrorZ +pub union CResult_TxRemoveOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveOutputDecodeErrorZ { + /// The contents of this CResult_TxRemoveOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveOutputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveOutput) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_is_ok(o: &CResult_TxRemoveOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveOutputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_free(_res: CResult_TxRemoveOutputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_clone(orig: &CResult_TxRemoveOutputDecodeErrorZ) -> CResult_TxRemoveOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxCompleteDecodeErrorZ +pub union CResult_TxCompleteDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxComplete, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxCompleteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxComplete on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxCompleteDecodeErrorZ { + /// The contents of this CResult_TxCompleteDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxCompleteDecodeErrorZPtr, + /// Whether this CResult_TxCompleteDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxComplete) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_is_ok(o: &CResult_TxCompleteDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxCompleteDecodeErrorZ. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_free(_res: CResult_TxCompleteDecodeErrorZ) { } +impl Drop for CResult_TxCompleteDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxCompleteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxCompleteDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxCompleteDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxCompleteDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_clone(orig: &CResult_TxCompleteDecodeErrorZ) -> CResult_TxCompleteDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxSignaturesDecodeErrorZ +pub union CResult_TxSignaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxSignaturesDecodeErrorZ { + /// The contents of this CResult_TxSignaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxSignaturesDecodeErrorZPtr, + /// Whether this CResult_TxSignaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxSignatures) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_is_ok(o: &CResult_TxSignaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxSignaturesDecodeErrorZ. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_free(_res: CResult_TxSignaturesDecodeErrorZ) { } +impl Drop for CResult_TxSignaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxSignaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxSignaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxSignaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_clone(orig: &CResult_TxSignaturesDecodeErrorZ) -> CResult_TxSignaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxInitRbfDecodeErrorZ +pub union CResult_TxInitRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxInitRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxInitRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxInitRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxInitRbfDecodeErrorZ { + /// The contents of this CResult_TxInitRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxInitRbfDecodeErrorZPtr, + /// Whether this CResult_TxInitRbfDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxInitRbf) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_is_ok(o: &CResult_TxInitRbfDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxInitRbfDecodeErrorZ. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_free(_res: CResult_TxInitRbfDecodeErrorZ) { } +impl Drop for CResult_TxInitRbfDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxInitRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxInitRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxInitRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxInitRbfDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_clone(orig: &CResult_TxInitRbfDecodeErrorZ) -> CResult_TxInitRbfDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAckRbfDecodeErrorZ +pub union CResult_TxAckRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAckRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAckRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAckRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAckRbfDecodeErrorZ { + /// The contents of this CResult_TxAckRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAckRbfDecodeErrorZPtr, + /// Whether this CResult_TxAckRbfDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAckRbf) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_is_ok(o: &CResult_TxAckRbfDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAckRbfDecodeErrorZ. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_free(_res: CResult_TxAckRbfDecodeErrorZ) { } +impl Drop for CResult_TxAckRbfDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAckRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAckRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAckRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAckRbfDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_clone(orig: &CResult_TxAckRbfDecodeErrorZ) -> CResult_TxAckRbfDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAbortDecodeErrorZ +pub union CResult_TxAbortDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAbort, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAbortDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAbort on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAbortDecodeErrorZ { + /// The contents of this CResult_TxAbortDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAbortDecodeErrorZPtr, + /// Whether this CResult_TxAbortDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAbort) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAbortDecodeErrorZ_is_ok(o: &CResult_TxAbortDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAbortDecodeErrorZ. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_free(_res: CResult_TxAbortDecodeErrorZ) { } +impl Drop for CResult_TxAbortDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAbortDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAbortDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAbortDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAbortDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAbortDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAbortDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_clone(orig: &CResult_TxAbortDecodeErrorZ) -> CResult_TxAbortDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ +pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AnnouncementSignaturesDecodeErrorZ { + /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, + /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } +impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AnnouncementSignaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelReestablishDecodeErrorZ +pub union CResult_ChannelReestablishDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelReestablishDecodeErrorZ { + /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelReestablishDecodeErrorZPtr, + /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } +impl Drop for CResult_ChannelReestablishDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelReestablishDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelReestablishDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelReestablishDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelReestablishDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ClosingSignedDecodeErrorZ +pub union CResult_ClosingSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ClosingSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ClosingSignedDecodeErrorZ { + /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ClosingSignedDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ClosingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ClosingSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ClosingSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ClosingSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ +pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { + /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_CommitmentSignedDecodeErrorZ +pub union CResult_CommitmentSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CommitmentSignedDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CommitmentSignedDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CommitmentSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CommitmentSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CommitmentSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CommitmentSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_FundingCreatedDecodeErrorZ +pub union CResult_FundingCreatedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::FundingCreated, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FundingCreatedDecodeErrorZ { + /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FundingCreatedDecodeErrorZPtr, + /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } +impl Drop for CResult_FundingCreatedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FundingCreatedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FundingCreatedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FundingCreatedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FundingCreatedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_FundingSignedDecodeErrorZ +pub union CResult_FundingSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::FundingSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FundingSignedDecodeErrorZ { + /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FundingSignedDecodeErrorZPtr, + /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } +impl Drop for CResult_FundingSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FundingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FundingSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FundingSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FundingSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelReadyDecodeErrorZ +pub union CResult_ChannelReadyDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelReady, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelReadyDecodeErrorZ { + /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelReadyDecodeErrorZPtr, + /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } +impl Drop for CResult_ChannelReadyDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelReadyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelReadyDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelReadyDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelReadyDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InitDecodeErrorZ +pub union CResult_InitDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Init, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InitDecodeErrorZ { + /// The contents of this CResult_InitDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InitDecodeErrorZPtr, + /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InitDecodeErrorZ. +pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } +impl Drop for CResult_InitDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InitDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InitDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InitDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InitDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OpenChannelDecodeErrorZ +pub union CResult_OpenChannelDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OpenChannel, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OpenChannelDecodeErrorZ { + /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OpenChannelDecodeErrorZPtr, + /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } +impl Drop for CResult_OpenChannelDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OpenChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OpenChannelDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OpenChannelDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OpenChannelDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OpenChannelV2DecodeErrorZ +pub union CResult_OpenChannelV2DecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OpenChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OpenChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OpenChannelV2DecodeErrorZ { + /// The contents of this CResult_OpenChannelV2DecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OpenChannelV2DecodeErrorZPtr, + /// Whether this CResult_OpenChannelV2DecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannelV2) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_is_ok(o: &CResult_OpenChannelV2DecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OpenChannelV2DecodeErrorZ. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_free(_res: CResult_OpenChannelV2DecodeErrorZ) { } +impl Drop for CResult_OpenChannelV2DecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OpenChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OpenChannelV2DecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OpenChannelV2DecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OpenChannelV2DecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OpenChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_clone(orig: &CResult_OpenChannelV2DecodeErrorZ) -> CResult_OpenChannelV2DecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_RevokeAndACKDecodeErrorZ +pub union CResult_RevokeAndACKDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RevokeAndACKDecodeErrorZ { + /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RevokeAndACKDecodeErrorZPtr, + /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } +impl Drop for CResult_RevokeAndACKDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RevokeAndACKDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RevokeAndACKDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RevokeAndACKDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RevokeAndACKDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ShutdownDecodeErrorZ +pub union CResult_ShutdownDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Shutdown, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ShutdownDecodeErrorZ { + /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ShutdownDecodeErrorZPtr, + /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } +impl Drop for CResult_ShutdownDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ShutdownDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ShutdownDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ShutdownDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ShutdownDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFailHTLCDecodeErrorZ +pub union CResult_UpdateFailHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFailHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFailHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFailHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFailHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFailHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ +pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFeeDecodeErrorZ +pub union CResult_UpdateFeeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFee, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFeeDecodeErrorZ { + /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFeeDecodeErrorZPtr, + /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } +impl Drop for CResult_UpdateFeeDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFeeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFeeDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFeeDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFeeDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ +pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateAddHTLCDecodeErrorZ +pub union CResult_UpdateAddHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateAddHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateAddHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateAddHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateAddHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateAddHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OnionMessageDecodeErrorZ +pub union CResult_OnionMessageDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OnionMessage, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OnionMessageDecodeErrorZ { + /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OnionMessageDecodeErrorZPtr, + /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } +impl Drop for CResult_OnionMessageDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OnionMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OnionMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OnionMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OnionMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PingDecodeErrorZ +pub union CResult_PingDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Ping, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PingDecodeErrorZ { + /// The contents of this CResult_PingDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PingDecodeErrorZPtr, + /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ in the success state. +pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ in the error state. +pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PingDecodeErrorZ. +pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } +impl Drop for CResult_PingDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PingDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PingDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PingDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PingDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PongDecodeErrorZ +pub union CResult_PongDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Pong, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PongDecodeErrorZ { + /// The contents of this CResult_PongDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PongDecodeErrorZPtr, + /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ in the success state. +pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ in the error state. +pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PongDecodeErrorZ. +pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } +impl Drop for CResult_PongDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PongDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PongDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PongDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PongDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ +pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelAnnouncementDecodeErrorZ +pub union CResult_ChannelAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelAnnouncementDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ +pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_BalanceZ { +impl Clone for CResult_UnsignedChannelUpdateDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// The contents of CResult_ChannelUpdateDecodeErrorZ +pub union CResult_ChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, + pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either +pub struct CResult_ChannelUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + pub contents: CResult_ChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12182,13 +15523,13 @@ pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: cr } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12201,16 +15542,16 @@ impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } + CResult_ChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } + CResult_ChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -12218,142 +15559,155 @@ impl From for C2Tuple_PublicKeyTypeZ { - fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { - Self { - a: tup.0, - b: tup.1, +impl Clone for CResult_ChannelUpdateDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } -impl C2Tuple_PublicKeyTypeZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { - C2Tuple_PublicKeyTypeZ { a, b, } +/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ErrorMessageDecodeErrorZ +pub union CResult_ErrorMessageDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ErrorMessage, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. -pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyTypeZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ErrorMessageDecodeErrorZ { + /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ErrorMessageDecodeErrorZPtr, + /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_PublicKeyTypeZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_PublicKeyTypeZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } +impl Drop for CResult_ErrorMessageDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not -pub enum COption_CustomOnionMessageContentsZ { - /// When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents - Some(crate::lightning::onion_message::packet::CustomOnionMessageContents), - /// When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing - None -} -impl COption_CustomOnionMessageContentsZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::CustomOnionMessageContents { - if let Self::Some(v) = self { v } else { unreachable!() } +impl From> for CResult_ErrorMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ErrorMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ErrorMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -#[no_mangle] -/// Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents -pub extern "C" fn COption_CustomOnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> COption_CustomOnionMessageContentsZ { - COption_CustomOnionMessageContentsZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_CustomOnionMessageContentsZ containing nothing -pub extern "C" fn COption_CustomOnionMessageContentsZ_none() -> COption_CustomOnionMessageContentsZ { - COption_CustomOnionMessageContentsZ::None +impl Clone for CResult_ErrorMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state -pub extern "C" fn COption_CustomOnionMessageContentsZ_free(_res: COption_CustomOnionMessageContentsZ) { } +/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ -pub union CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// The contents of CResult_WarningMessageDecodeErrorZ +pub union CResult_WarningMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_CustomOnionMessageContentsZ, + pub result: *mut crate::lightning::ln::msgs::WarningMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - /// The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either +pub struct CResult_WarningMessageDecodeErrorZ { + /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr, - /// Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. + pub contents: CResult_WarningMessageDecodeErrorZPtr, + /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_CustomOnionMessageContentsZ) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12361,13 +15715,13 @@ pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) { } -impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { +/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } +impl Drop for CResult_WarningMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12380,16 +15734,16 @@ impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { } } } -impl From> for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WarningMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result } + CResult_WarningMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err } + CResult_WarningMessageDecodeErrorZPtr { err } }; Self { contents, @@ -12397,167 +15751,155 @@ impl From bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::NetAddress { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_WarningMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress -pub extern "C" fn COption_NetAddressZ_some(o: crate::lightning::ln::msgs::NetAddress) -> COption_NetAddressZ { - COption_NetAddressZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_NetAddressZ containing nothing -pub extern "C" fn COption_NetAddressZ_none() -> COption_NetAddressZ { - COption_NetAddressZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state -pub extern "C" fn COption_NetAddressZ_free(_res: COption_NetAddressZ) { } -#[no_mangle] -/// Creates a new COption_NetAddressZ which has the same data as `orig` +/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetAddressZ_clone(orig: &COption_NetAddressZ) -> COption_NetAddressZ { Clone::clone(&orig) } +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyCOption_NetAddressZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::c_types::derived::COption_NetAddressZ, +/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ +pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)> for C2Tuple_PublicKeyCOption_NetAddressZZ { - fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_PublicKeyCOption_NetAddressZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_PublicKeyCOption_NetAddressZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig: &C2Tuple_PublicKeyCOption_NetAddressZZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::COption_NetAddressZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { - C2Tuple_PublicKeyCOption_NetAddressZZ { a, b, } +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res: C2Tuple_PublicKeyCOption_NetAddressZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { +impl Clone for CResult_UnsignedNodeAnnouncementDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_u8ZPeerHandleErrorZ -pub union CResult_CVec_u8ZPeerHandleErrorZPtr { +/// The contents of CResult_NodeAnnouncementDecodeErrorZ +pub union CResult_NodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, + pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZPeerHandleErrorZ { - /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either +pub struct CResult_NodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, - /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12565,13 +15907,13 @@ pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } -impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { +/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12584,16 +15926,16 @@ impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { } } } -impl From> for CResult_CVec_u8ZPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_u8ZPeerHandleErrorZPtr { result } + CResult_NodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_u8ZPeerHandleErrorZPtr { err } + CResult_NodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -12601,58 +15943,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePeerHandleErrorZ -pub union CResult_NonePeerHandleErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ +pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePeerHandleErrorZ { - /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either +pub struct CResult_QueryShortChannelIdsDecodeErrorZ { + /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePeerHandleErrorZPtr, - /// Whether this CResult_NonePeerHandleErrorZ represents a success state. + pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, + /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the success state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the error state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12660,15 +16003,18 @@ pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePeerHandleErrorZ. -pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } -impl Drop for CResult_NonePeerHandleErrorZ { +/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } +impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -12676,16 +16022,16 @@ impl Drop for CResult_NonePeerHandleErrorZ { } } } -impl From> for CResult_NonePeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { +impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_QueryShortChannelIdsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePeerHandleErrorZPtr { err } + CResult_QueryShortChannelIdsDecodeErrorZPtr { err } }; Self { contents, @@ -12693,59 +16039,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_boolPeerHandleErrorZ -pub union CResult_boolPeerHandleErrorZPtr { +/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ +pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, + pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolPeerHandleErrorZ { - /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either +pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { + /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolPeerHandleErrorZPtr, - /// Whether this CResult_boolPeerHandleErrorZ represents a success state. + pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, + /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12753,13 +16099,13 @@ pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_boolPeerHandleErrorZ. -pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } -impl Drop for CResult_boolPeerHandleErrorZ { +/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } +impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12772,16 +16118,16 @@ impl Drop for CResult_boolPeerHandleErrorZ { } } } -impl From> for CResult_boolPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_boolPeerHandleErrorZPtr { result } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_boolPeerHandleErrorZPtr { err } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } }; Self { contents, @@ -12789,59 +16135,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxOutUtxoLookupErrorZ -pub union CResult_TxOutUtxoLookupErrorZPtr { +/// The contents of CResult_QueryChannelRangeDecodeErrorZ +pub union CResult_QueryChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::TxOut, + pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. +/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxOutUtxoLookupErrorZ { - /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either +pub struct CResult_QueryChannelRangeDecodeErrorZ { + /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxOutUtxoLookupErrorZPtr, - /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. + pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, + /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12849,13 +16195,13 @@ pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } -impl Drop for CResult_TxOutUtxoLookupErrorZ { +/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } +impl Drop for CResult_QueryChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12868,16 +16214,16 @@ impl Drop for CResult_TxOutUtxoLookupErrorZ { } } } -impl From> for CResult_TxOutUtxoLookupErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxOutUtxoLookupErrorZPtr { result } + CResult_QueryChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxOutUtxoLookupErrorZPtr { err } + CResult_QueryChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -12885,58 +16231,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneSendErrorZ -pub union CResult_NoneSendErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ReplyChannelRangeDecodeErrorZ +pub union CResult_ReplyChannelRangeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneSendErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. +/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneSendErrorZ { - /// The contents of this CResult_NoneSendErrorZ, accessible via either +pub struct CResult_ReplyChannelRangeDecodeErrorZ { + /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneSendErrorZPtr, - /// Whether this CResult_NoneSendErrorZ represents a success state. + pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, + /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneSendErrorZ in the success state. -pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ { - CResult_NoneSendErrorZ { - contents: CResult_NoneSendErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneSendErrorZ in the error state. -pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ { - CResult_NoneSendErrorZ { - contents: CResult_NoneSendErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12944,15 +16291,18 @@ pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool { +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneSendErrorZ. -pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { } -impl Drop for CResult_NoneSendErrorZ { +/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } +impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -12960,16 +16310,16 @@ impl Drop for CResult_NoneSendErrorZ { } } } -impl From> for CResult_NoneSendErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { +impl From> for CResult_ReplyChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ReplyChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneSendErrorZPtr { err } + CResult_ReplyChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -12977,74 +16327,95 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathNoneZ -pub union CResult_BlindedPathNoneZPtr { +/// The contents of CResult_GossipTimestampFilterDecodeErrorZ +pub union CResult_GossipTimestampFilterDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. +/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathNoneZ { - /// The contents of this CResult_BlindedPathNoneZ, accessible via either +pub struct CResult_GossipTimestampFilterDecodeErrorZ { + /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathNoneZPtr, - /// Whether this CResult_BlindedPathNoneZ represents a success state. + pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, + /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the success state. -pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the error state. -pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> bool { +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathNoneZ. -pub extern "C" fn CResult_BlindedPathNoneZ_free(_res: CResult_BlindedPathNoneZ) { } -impl Drop for CResult_BlindedPathNoneZ { +/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } +impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_BlindedPathNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_GossipTimestampFilterDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathNoneZPtr { result } + CResult_GossipTimestampFilterDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_GossipTimestampFilterDecodeErrorZPtr { err } }; Self { contents, @@ -13052,59 +16423,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathDecodeErrorZ -pub union CResult_BlindedPathDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PhantomRouteHintsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PhantomRouteHintsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PhantomRouteHintsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } +impl Drop for CVec_PhantomRouteHintsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PhantomRouteHintsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ +pub union CResult_Bolt11InvoiceSignOrCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::SignOrCreationError, } #[repr(C)] -/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathDecodeErrorZ { - /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceSignOrCreationErrorZ { + /// The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathDecodeErrorZPtr, - /// Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr, + /// Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } -#[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +#[no_mangle] +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13112,13 +16529,13 @@ pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathDecodeErrorZ. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_free(_res: CResult_BlindedPathDecodeErrorZ) { } -impl Drop for CResult_BlindedPathDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res: CResult_Bolt11InvoiceSignOrCreationErrorZ) { } +impl Drop for CResult_Bolt11InvoiceSignOrCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13131,16 +16548,16 @@ impl Drop for CResult_BlindedPathDecodeErrorZ { } } } -impl From> for CResult_BlindedPathDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceSignOrCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathDecodeErrorZPtr { result } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPathDecodeErrorZPtr { err } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } }; Self { contents, @@ -13148,59 +16565,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedHopDecodeErrorZ -pub union CResult_BlindedHopDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_FutureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::wakers::Future, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_FutureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_FutureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } +impl Drop for CVec_FutureZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_FutureZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_OffersMessageDecodeErrorZ +pub union CResult_OffersMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedHop, + pub result: *mut crate::lightning::onion_message::offers::OffersMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OffersMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::offers::OffersMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopDecodeErrorZ { - /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either +pub struct CResult_OffersMessageDecodeErrorZ { + /// The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopDecodeErrorZPtr, - /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + pub contents: CResult_OffersMessageDecodeErrorZPtr, + /// Whether this CResult_OffersMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::offers::OffersMessage) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13208,13 +16671,13 @@ pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } -impl Drop for CResult_BlindedHopDecodeErrorZ { +/// Frees any resources used by the CResult_OffersMessageDecodeErrorZ. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_free(_res: CResult_OffersMessageDecodeErrorZ) { } +impl Drop for CResult_OffersMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13227,16 +16690,16 @@ impl Drop for CResult_BlindedHopDecodeErrorZ { } } } -impl From> for CResult_BlindedHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OffersMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopDecodeErrorZPtr { result } + CResult_OffersMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopDecodeErrorZPtr { err } + CResult_OffersMessageDecodeErrorZPtr { err } }; Self { contents, @@ -13244,59 +16707,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OffersMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_clone(orig: &CResult_OffersMessageDecodeErrorZ) -> CResult_OffersMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not +pub enum COption_HTLCClaimZ { + /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + Some(crate::lightning::ln::chan_utils::HTLCClaim), + /// When we're in this state, this COption_HTLCClaimZ contains nothing + None +} +impl COption_HTLCClaimZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim +pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { + COption_HTLCClaimZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing nothing +pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { + COption_HTLCClaimZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state +pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } #[repr(C)] -/// The contents of CResult_SiPrefixParseErrorZ -pub union CResult_SiPrefixParseErrorZPtr { +/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ +pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SiPrefix, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. +/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SiPrefixParseErrorZ { - /// The contents of this CResult_SiPrefixParseErrorZ, accessible via either +pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SiPrefixParseErrorZPtr, - /// Whether this CResult_SiPrefixParseErrorZ represents a success state. + pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, + /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ in the success state. -pub extern "C" fn CResult_SiPrefixParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixParseErrorZ { - CResult_SiPrefixParseErrorZ { - contents: CResult_SiPrefixParseErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ in the error state. -pub extern "C" fn CResult_SiPrefixParseErrorZ_err(e: crate::lightning_invoice::ParseError) -> CResult_SiPrefixParseErrorZ { - CResult_SiPrefixParseErrorZ { - contents: CResult_SiPrefixParseErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13304,13 +16799,13 @@ pub extern "C" fn CResult_SiPrefixParseErrorZ_err(e: crate::lightning_invoice::P } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SiPrefixParseErrorZ_is_ok(o: &CResult_SiPrefixParseErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SiPrefixParseErrorZ. -pub extern "C" fn CResult_SiPrefixParseErrorZ_free(_res: CResult_SiPrefixParseErrorZ) { } -impl Drop for CResult_SiPrefixParseErrorZ { +/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } +impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13323,16 +16818,16 @@ impl Drop for CResult_SiPrefixParseErrorZ { } } } -impl From> for CResult_SiPrefixParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SiPrefixParseErrorZPtr { result } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SiPrefixParseErrorZPtr { err } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } }; Self { contents, @@ -13340,59 +16835,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SiPrefixParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SiPrefixParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SiPrefixParseErrorZ_clone(orig: &CResult_SiPrefixParseErrorZ) -> CResult_SiPrefixParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceParseOrSemanticErrorZ -pub union CResult_InvoiceParseOrSemanticErrorZPtr { +/// The contents of CResult_TxCreationKeysDecodeErrorZ +pub union CResult_TxCreationKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseOrSemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. +/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceParseOrSemanticErrorZ { - /// The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either +pub struct CResult_TxCreationKeysDecodeErrorZ { + /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceParseOrSemanticErrorZPtr, - /// Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. + pub contents: CResult_TxCreationKeysDecodeErrorZPtr, + /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceParseOrSemanticErrorZ { - CResult_InvoiceParseOrSemanticErrorZ { - contents: CResult_InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_InvoiceParseOrSemanticErrorZ { - CResult_InvoiceParseOrSemanticErrorZ { - contents: CResult_InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13400,13 +16895,13 @@ pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_i } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_InvoiceParseOrSemanticErrorZ) -> bool { +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_free(_res: CResult_InvoiceParseOrSemanticErrorZ) { } -impl Drop for CResult_InvoiceParseOrSemanticErrorZ { +/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } +impl Drop for CResult_TxCreationKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13419,16 +16914,16 @@ impl Drop for CResult_InvoiceParseOrSemanticErrorZ { } } } -impl From> for CResult_InvoiceParseOrSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxCreationKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceParseOrSemanticErrorZPtr { result } + CResult_TxCreationKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceParseOrSemanticErrorZPtr { err } + CResult_TxCreationKeysDecodeErrorZPtr { err } }; Self { contents, @@ -13436,59 +16931,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceParseOrSemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceParseOrSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_InvoiceParseOrSemanticErrorZ) -> CResult_InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignedRawInvoiceParseErrorZ -pub union CResult_SignedRawInvoiceParseErrorZPtr { +/// The contents of CResult_ChannelPublicKeysDecodeErrorZ +pub union CResult_ChannelPublicKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SignedRawInvoice, + pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. +/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignedRawInvoiceParseErrorZ { - /// The contents of this CResult_SignedRawInvoiceParseErrorZ, accessible via either +pub struct CResult_ChannelPublicKeysDecodeErrorZ { + /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignedRawInvoiceParseErrorZPtr, - /// Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. + pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, + /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_ok(o: crate::lightning_invoice::SignedRawInvoice) -> CResult_SignedRawInvoiceParseErrorZ { - CResult_SignedRawInvoiceParseErrorZ { - contents: CResult_SignedRawInvoiceParseErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_err(e: crate::lightning_invoice::ParseError) -> CResult_SignedRawInvoiceParseErrorZ { - CResult_SignedRawInvoiceParseErrorZ { - contents: CResult_SignedRawInvoiceParseErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13496,13 +16991,13 @@ pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_err(e: crate::lightning_in } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_is_ok(o: &CResult_SignedRawInvoiceParseErrorZ) -> bool { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_free(_res: CResult_SignedRawInvoiceParseErrorZ) { } -impl Drop for CResult_SignedRawInvoiceParseErrorZ { +/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } +impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13511,126 +17006,80 @@ impl Drop for CResult_SignedRawInvoiceParseErrorZ { } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_SignedRawInvoiceParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignedRawInvoiceParseErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SignedRawInvoiceParseErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_SignedRawInvoiceParseErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_SignedRawInvoiceParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_SignedRawInvoiceParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_clone(orig: &CResult_SignedRawInvoiceParseErrorZ) -> CResult_SignedRawInvoiceParseErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_RawInvoice_u832InvoiceSignatureZ { - /// The element at position 0 - pub a: crate::lightning_invoice::RawInvoice, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, - /// The element at position 2 - pub c: crate::lightning_invoice::InvoiceSignature, -} -impl From<(crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)> for C3Tuple_RawInvoice_u832InvoiceSignatureZ { - fn from (tup: (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, + } } } } -impl C3Tuple_RawInvoice_u832InvoiceSignatureZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature) { - (self.a, self.b, self.c) +impl From> for CResult_ChannelPublicKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelPublicKeysDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelPublicKeysDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C3Tuple_RawInvoice_u832InvoiceSignatureZ { +impl Clone for CResult_ChannelPublicKeysDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig: &C3Tuple_RawInvoice_u832InvoiceSignatureZ) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a: crate::lightning_invoice::RawInvoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::InvoiceSignature) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { - C3Tuple_RawInvoice_u832InvoiceSignatureZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res: C3Tuple_RawInvoice_u832InvoiceSignatureZ) { } +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PayeePubKeyErrorZ -pub union CResult_PayeePubKeyErrorZPtr { +/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ +pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PayeePubKey, + pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PayeePubKeyErrorZ { - /// The contents of this CResult_PayeePubKeyErrorZ, accessible via either +pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { + /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PayeePubKeyErrorZPtr, - /// Whether this CResult_PayeePubKeyErrorZ represents a success state. + pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, + /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ in the success state. -pub extern "C" fn CResult_PayeePubKeyErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeyErrorZ { - CResult_PayeePubKeyErrorZ { - contents: CResult_PayeePubKeyErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ in the error state. -pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeyErrorZ { - CResult_PayeePubKeyErrorZ { - contents: CResult_PayeePubKeyErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13638,13 +17087,13 @@ pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Erro } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PayeePubKeyErrorZ_is_ok(o: &CResult_PayeePubKeyErrorZ) -> bool { +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PayeePubKeyErrorZ. -pub extern "C" fn CResult_PayeePubKeyErrorZ_free(_res: CResult_PayeePubKeyErrorZ) { } -impl Drop for CResult_PayeePubKeyErrorZ { +/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } +impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13657,16 +17106,16 @@ impl Drop for CResult_PayeePubKeyErrorZ { } } } -impl From> for CResult_PayeePubKeyErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PayeePubKeyErrorZPtr { result } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PayeePubKeyErrorZPtr { err } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } }; Self { contents, @@ -13674,105 +17123,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PayeePubKeyErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PayeePubKeyErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PrivateRouteZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning_invoice::PrivateRoute, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PrivateRouteZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PrivateRouteZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } -impl Drop for CVec_PrivateRouteZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PrivateRouteZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PositiveTimestampCreationErrorZ -pub union CResult_PositiveTimestampCreationErrorZPtr { +/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ +pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PositiveTimestamp, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PositiveTimestampCreationErrorZ { - /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either +pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PositiveTimestampCreationErrorZPtr, - /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13780,13 +17183,13 @@ pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } -impl Drop for CResult_PositiveTimestampCreationErrorZ { +/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13799,16 +17202,16 @@ impl Drop for CResult_PositiveTimestampCreationErrorZ { } } } -impl From> for CResult_PositiveTimestampCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PositiveTimestampCreationErrorZPtr { result } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PositiveTimestampCreationErrorZPtr { err } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -13816,58 +17219,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneSemanticErrorZ -pub union CResult_NoneSemanticErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ +pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneSemanticErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::SemanticError on failure. +/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneSemanticErrorZ { - /// The contents of this CResult_NoneSemanticErrorZ, accessible via either +pub struct CResult_ChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneSemanticErrorZPtr, - /// Whether this CResult_NoneSemanticErrorZ represents a success state. + pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ in the success state. -pub extern "C" fn CResult_NoneSemanticErrorZ_ok() -> CResult_NoneSemanticErrorZ { - CResult_NoneSemanticErrorZ { - contents: CResult_NoneSemanticErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ in the error state. -pub extern "C" fn CResult_NoneSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_NoneSemanticErrorZ { - CResult_NoneSemanticErrorZ { - contents: CResult_NoneSemanticErrorZPtr { +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13875,15 +17279,18 @@ pub extern "C" fn CResult_NoneSemanticErrorZ_err(e: crate::lightning_invoice::Se } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneSemanticErrorZ_is_ok(o: &CResult_NoneSemanticErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneSemanticErrorZ. -pub extern "C" fn CResult_NoneSemanticErrorZ_free(_res: CResult_NoneSemanticErrorZ) { } -impl Drop for CResult_NoneSemanticErrorZ { +/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -13891,16 +17298,16 @@ impl Drop for CResult_NoneSemanticErrorZ { } } } -impl From> for CResult_NoneSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::SemanticError>) -> Self { +impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneSemanticErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneSemanticErrorZPtr { err } + CResult_ChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -13908,59 +17315,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneSemanticErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneSemanticErrorZ_clone(orig: &CResult_NoneSemanticErrorZ) -> CResult_NoneSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceSemanticErrorZ -pub union CResult_InvoiceSemanticErrorZPtr { +/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ +pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. +/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceSemanticErrorZ { - /// The contents of this CResult_InvoiceSemanticErrorZ, accessible via either +pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceSemanticErrorZPtr, - /// Whether this CResult_InvoiceSemanticErrorZ represents a success state. + pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ in the success state. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceSemanticErrorZ { - CResult_InvoiceSemanticErrorZ { - contents: CResult_InvoiceSemanticErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ in the error state. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_InvoiceSemanticErrorZ { - CResult_InvoiceSemanticErrorZ { - contents: CResult_InvoiceSemanticErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13968,13 +17375,13 @@ pub extern "C" fn CResult_InvoiceSemanticErrorZ_err(e: crate::lightning_invoice: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceSemanticErrorZ_is_ok(o: &CResult_InvoiceSemanticErrorZ) -> bool { +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceSemanticErrorZ. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_free(_res: CResult_InvoiceSemanticErrorZ) { } -impl Drop for CResult_InvoiceSemanticErrorZ { +/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13987,16 +17394,16 @@ impl Drop for CResult_InvoiceSemanticErrorZ { } } } -impl From> for CResult_InvoiceSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceSemanticErrorZPtr { result } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceSemanticErrorZPtr { err } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14004,105 +17411,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceSemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_AddressZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Str, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_AddressZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_AddressZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } -impl Drop for CVec_AddressZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_AddressZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DescriptionCreationErrorZ -pub union CResult_DescriptionCreationErrorZPtr { +/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ +pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Description, + pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DescriptionCreationErrorZ { - /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either +pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DescriptionCreationErrorZPtr, - /// Whether this CResult_DescriptionCreationErrorZ represents a success state. + pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the success state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the error state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14110,13 +17471,13 @@ pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invo } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DescriptionCreationErrorZ. -pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } -impl Drop for CResult_DescriptionCreationErrorZ { +/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14129,16 +17490,16 @@ impl Drop for CResult_DescriptionCreationErrorZ { } } } -impl From> for CResult_DescriptionCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DescriptionCreationErrorZPtr { result } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DescriptionCreationErrorZPtr { err } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14146,95 +17507,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PrivateRouteCreationErrorZ -pub union CResult_PrivateRouteCreationErrorZPtr { +/// The contents of CResult_TrustedClosingTransactionNoneZ +pub union CResult_TrustedClosingTransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PrivateRoute, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PrivateRouteCreationErrorZ { - /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either +pub struct CResult_TrustedClosingTransactionNoneZ { + /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PrivateRouteCreationErrorZPtr, - /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + pub contents: CResult_TrustedClosingTransactionNoneZPtr, + /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } -impl Drop for CResult_PrivateRouteCreationErrorZ { +/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } +impl Drop for CResult_TrustedClosingTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_PrivateRouteCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrustedClosingTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PrivateRouteCreationErrorZPtr { result } + CResult_TrustedClosingTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PrivateRouteCreationErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -14242,59 +17599,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NetAddressDecodeErrorZ -pub union CResult_NetAddressDecodeErrorZPtr { +/// The contents of CResult_CommitmentTransactionDecodeErrorZ +pub union CResult_CommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::NetAddress, + pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NetAddressDecodeErrorZ { - /// The contents of this CResult_NetAddressDecodeErrorZ, accessible via either +pub struct CResult_CommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NetAddressDecodeErrorZPtr, - /// Whether this CResult_NetAddressDecodeErrorZ represents a success state. + pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ in the success state. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressDecodeErrorZ { - CResult_NetAddressDecodeErrorZ { - contents: CResult_NetAddressDecodeErrorZPtr { +} +#[no_mangle] +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ in the error state. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetAddressDecodeErrorZ { - CResult_NetAddressDecodeErrorZ { - contents: CResult_NetAddressDecodeErrorZPtr { +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14302,13 +17642,13 @@ pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NetAddressDecodeErrorZ_is_ok(o: &CResult_NetAddressDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NetAddressDecodeErrorZ. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_free(_res: CResult_NetAddressDecodeErrorZ) { } -impl Drop for CResult_NetAddressDecodeErrorZ { +/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_CommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14321,16 +17661,16 @@ impl Drop for CResult_NetAddressDecodeErrorZ { } } } -impl From> for CResult_NetAddressDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NetAddressDecodeErrorZPtr { result } + CResult_CommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NetAddressDecodeErrorZPtr { err } + CResult_CommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14338,279 +17678,166 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NetAddressDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NetAddressDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateAddHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateAddHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateAddHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } -impl Drop for CVec_UpdateAddHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateAddHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// The contents of CResult_TrustedCommitmentTransactionNoneZ +pub union CResult_TrustedCommitmentTransactionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFulfillHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFulfillHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFulfillHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TrustedCommitmentTransactionNoneZ { + /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, + /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } -impl Drop for CVec_UpdateFulfillHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFulfillHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFailHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } -impl Drop for CVec_UpdateFailHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFailHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailMalformedHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailMalformedHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, } } -impl From> for CVec_UpdateFailMalformedHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } -impl Drop for CVec_UpdateFailMalformedHTLCZ { +/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } +impl Drop for CResult_TrustedCommitmentTransactionNoneZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } } } -impl Clone for CVec_UpdateFailMalformedHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +impl From> for CResult_TrustedCommitmentTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TrustedCommitmentTransactionNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } } } #[repr(C)] -/// The contents of CResult_AcceptChannelDecodeErrorZ -pub union CResult_AcceptChannelDecodeErrorZPtr { +/// The contents of CResult_CVec_SignatureZNoneZ +pub union CResult_CVec_SignatureZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AcceptChannel, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_SignatureZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AcceptChannelDecodeErrorZ { - /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either +pub struct CResult_CVec_SignatureZNoneZ { + /// The contents of this CResult_CVec_SignatureZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AcceptChannelDecodeErrorZPtr, - /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub contents: CResult_CVec_SignatureZNoneZPtr, + /// Whether this CResult_CVec_SignatureZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_CVec_SignatureZNoneZ in the success state. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_ok(o: crate::c_types::derived::CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ { + CResult_CVec_SignatureZNoneZ { + contents: CResult_CVec_SignatureZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_SignatureZNoneZ in the error state. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { + CResult_CVec_SignatureZNoneZ { + contents: CResult_CVec_SignatureZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_SignatureZNoneZ_is_ok(o: &CResult_CVec_SignatureZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } -impl Drop for CResult_AcceptChannelDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_SignatureZNoneZ. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_free(_res: CResult_CVec_SignatureZNoneZ) { } +impl Drop for CResult_CVec_SignatureZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_AcceptChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_SignatureZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AcceptChannelDecodeErrorZPtr { result } + CResult_CVec_SignatureZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AcceptChannelDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_SignatureZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -14618,59 +17845,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_SignatureZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ -pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// The contents of CResult_ShutdownScriptDecodeErrorZ +pub union CResult_ShutdownScriptDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AnnouncementSignaturesDecodeErrorZ { - /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptDecodeErrorZ { + /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, - /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptDecodeErrorZPtr, + /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14678,13 +17905,13 @@ pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } -impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } +impl Drop for CResult_ShutdownScriptDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14697,16 +17924,16 @@ impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { } } } -impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + CResult_ShutdownScriptDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + CResult_ShutdownScriptDecodeErrorZPtr { err } }; Self { contents, @@ -14714,59 +17941,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReestablishDecodeErrorZ -pub union CResult_ChannelReestablishDecodeErrorZPtr { +/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ +pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, } #[repr(C)] -/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReestablishDecodeErrorZ { - /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { + /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReestablishDecodeErrorZPtr, - /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, + /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14774,13 +18001,13 @@ pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } -impl Drop for CResult_ChannelReestablishDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } +impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14793,16 +18020,16 @@ impl Drop for CResult_ChannelReestablishDecodeErrorZ { } } } -impl From> for CResult_ChannelReestablishDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReestablishDecodeErrorZPtr { result } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReestablishDecodeErrorZPtr { err } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } }; Self { contents, @@ -14810,59 +18037,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedDecodeErrorZ -pub union CResult_ClosingSignedDecodeErrorZPtr { +/// The contents of CResult_PaymentPurposeDecodeErrorZ +pub union CResult_PaymentPurposeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSigned, + pub result: *mut crate::lightning::events::PaymentPurpose, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedDecodeErrorZ { - /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either +pub struct CResult_PaymentPurposeDecodeErrorZ { + /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub contents: CResult_PaymentPurposeDecodeErrorZPtr, + /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14870,13 +18097,13 @@ pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } +impl Drop for CResult_PaymentPurposeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14889,16 +18116,16 @@ impl Drop for CResult_ClosingSignedDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentPurposeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedDecodeErrorZPtr { result } + CResult_PaymentPurposeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedDecodeErrorZPtr { err } + CResult_PaymentPurposeDecodeErrorZPtr { err } }; Self { contents, @@ -14906,59 +18133,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ -pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PathFailure or not +pub enum COption_PathFailureZ { + /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure + Some(crate::lightning::events::PathFailure), + /// When we're in this state, this COption_PathFailureZ contains nothing + None +} +impl COption_PathFailureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure +pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { + COption_PathFailureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PathFailureZ containing nothing +pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { + COption_PathFailureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state +pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } +#[no_mangle] +/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_PathFailureZDecodeErrorZ +pub union CResult_COption_PathFailureZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, + pub result: *mut crate::c_types::derived::COption_PathFailureZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { - /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either +pub struct CResult_COption_PathFailureZDecodeErrorZ { + /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, + /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14966,13 +18230,13 @@ pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { +/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } +impl Drop for CResult_COption_PathFailureZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14985,16 +18249,16 @@ impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_PathFailureZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } + CResult_COption_PathFailureZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } + CResult_COption_PathFailureZDecodeErrorZPtr { err } }; Self { contents, @@ -15002,59 +18266,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CommitmentSignedDecodeErrorZ -pub union CResult_CommitmentSignedDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::ClosureReason or not +pub enum COption_ClosureReasonZ { + /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason + Some(crate::lightning::events::ClosureReason), + /// When we're in this state, this COption_ClosureReasonZ contains nothing + None +} +impl COption_ClosureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason +pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { + COption_ClosureReasonZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ClosureReasonZ containing nothing +pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { + COption_ClosureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state +pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } +#[no_mangle] +/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ +pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentSignedDecodeErrorZ { - /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either +pub struct CResult_COption_ClosureReasonZDecodeErrorZ { + /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentSignedDecodeErrorZPtr, - /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, + /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15062,13 +18363,13 @@ pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } -impl Drop for CResult_CommitmentSignedDecodeErrorZ { +/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } +impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15081,16 +18382,16 @@ impl Drop for CResult_CommitmentSignedDecodeErrorZ { } } } -impl From> for CResult_CommitmentSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentSignedDecodeErrorZPtr { result } + CResult_COption_ClosureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentSignedDecodeErrorZPtr { err } + CResult_COption_ClosureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -15098,59 +18399,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::HTLCDestination or not +pub enum COption_HTLCDestinationZ { + /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination + Some(crate::lightning::events::HTLCDestination), + /// When we're in this state, this COption_HTLCDestinationZ contains nothing + None +} +impl COption_HTLCDestinationZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination +pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing nothing +pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state +pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +#[no_mangle] +/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingCreatedDecodeErrorZ -pub union CResult_FundingCreatedDecodeErrorZPtr { +/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ +pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingCreated, + pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingCreatedDecodeErrorZ { - /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either +pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { + /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingCreatedDecodeErrorZPtr, - /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, + /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15158,13 +18496,13 @@ pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } -impl Drop for CResult_FundingCreatedDecodeErrorZ { +/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } +impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15177,16 +18515,16 @@ impl Drop for CResult_FundingCreatedDecodeErrorZ { } } } -impl From> for CResult_FundingCreatedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingCreatedDecodeErrorZPtr { result } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingCreatedDecodeErrorZPtr { err } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } }; Self { contents, @@ -15194,59 +18532,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingSignedDecodeErrorZ -pub union CResult_FundingSignedDecodeErrorZPtr { +/// The contents of CResult_PaymentFailureReasonDecodeErrorZ +pub union CResult_PaymentFailureReasonDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingSigned, + pub result: *mut crate::lightning::events::PaymentFailureReason, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingSignedDecodeErrorZ { - /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either +pub struct CResult_PaymentFailureReasonDecodeErrorZ { + /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingSignedDecodeErrorZPtr, - /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, + /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15254,13 +18592,13 @@ pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } -impl Drop for CResult_FundingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } +impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15273,16 +18611,16 @@ impl Drop for CResult_FundingSignedDecodeErrorZ { } } } -impl From> for CResult_FundingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentFailureReasonDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingSignedDecodeErrorZPtr { result } + CResult_PaymentFailureReasonDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingSignedDecodeErrorZPtr { err } + CResult_PaymentFailureReasonDecodeErrorZPtr { err } }; Self { contents, @@ -15290,59 +18628,207 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::U128 or not +pub enum COption_u128Z { + /// When we're in this state, this COption_u128Z contains a crate::c_types::U128 + Some(crate::c_types::U128), + /// When we're in this state, this COption_u128Z contains nothing + None +} +impl COption_u128Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u128Z containing a crate::c_types::U128 +pub extern "C" fn COption_u128Z_some(o: crate::c_types::U128) -> COption_u128Z { + COption_u128Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u128Z containing nothing +pub extern "C" fn COption_u128Z_none() -> COption_u128Z { + COption_u128Z::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state +pub extern "C" fn COption_u128Z_free(_res: COption_u128Z) { } +#[no_mangle] +/// Creates a new COption_u128Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentIdZ { + /// When we're in this state, this COption_PaymentIdZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentIdZ contains nothing + None +} +impl COption_PaymentIdZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentIdZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentIdZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentIdZ { + COption_PaymentIdZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentIdZ containing nothing +pub extern "C" fn COption_PaymentIdZ_none() -> COption_PaymentIdZ { + COption_PaymentIdZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentIdZ_free(_res: COption_PaymentIdZ) { } +#[no_mangle] +/// Creates a new COption_PaymentIdZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentIdZ_clone(orig: &COption_PaymentIdZ) -> COption_PaymentIdZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not +pub enum COption_PaymentFailureReasonZ { + /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason + Some(crate::lightning::events::PaymentFailureReason), + /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing + None +} +impl COption_PaymentFailureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason +pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing nothing +pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state +pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } +#[no_mangle] +/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::Event or not +pub enum COption_EventZ { + /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event + Some(crate::lightning::events::Event), + /// When we're in this state, this COption_EventZ contains nothing + None +} +impl COption_EventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_EventZ containing a crate::lightning::events::Event +pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { + COption_EventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_EventZ containing nothing +pub extern "C" fn COption_EventZ_none() -> COption_EventZ { + COption_EventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state +pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } +#[no_mangle] +/// Creates a new COption_EventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReadyDecodeErrorZ -pub union CResult_ChannelReadyDecodeErrorZPtr { +/// The contents of CResult_COption_EventZDecodeErrorZ +pub union CResult_COption_EventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReady, + pub result: *mut crate::c_types::derived::COption_EventZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReadyDecodeErrorZ { - /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either +pub struct CResult_COption_EventZDecodeErrorZ { + /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReadyDecodeErrorZPtr, - /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + pub contents: CResult_COption_EventZDecodeErrorZPtr, + /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15350,13 +18836,13 @@ pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } -impl Drop for CResult_ChannelReadyDecodeErrorZ { +/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } +impl Drop for CResult_COption_EventZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15369,16 +18855,16 @@ impl Drop for CResult_ChannelReadyDecodeErrorZ { } } } -impl From> for CResult_ChannelReadyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_EventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReadyDecodeErrorZPtr { result } + CResult_COption_EventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReadyDecodeErrorZPtr { err } + CResult_COption_EventZDecodeErrorZPtr { err } }; Self { contents, @@ -15386,59 +18872,97 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InitDecodeErrorZ -pub union CResult_InitDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_BlockHashChannelMonitorZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_BlockHashChannelMonitorZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_BlockHashChannelMonitorZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res: CVec_C2Tuple_BlockHashChannelMonitorZZ) { } +impl Drop for CVec_C2Tuple_BlockHashChannelMonitorZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ +pub union CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Init, + pub result: *mut crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::IOError, } #[repr(C)] -/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitDecodeErrorZ { - /// The contents of this CResult_InitDecodeErrorZ, accessible via either +pub struct CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + /// The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitDecodeErrorZPtr, - /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr, + /// Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15446,13 +18970,13 @@ pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o: &CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InitDecodeErrorZ. -pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } -impl Drop for CResult_InitDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) { } +impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15465,16 +18989,16 @@ impl Drop for CResult_InitDecodeErrorZ { } } } -impl From> for CResult_InitDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitDecodeErrorZPtr { result } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitDecodeErrorZPtr { err } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err } }; Self { contents, @@ -15482,59 +19006,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OpenChannelDecodeErrorZ -pub union CResult_OpenChannelDecodeErrorZPtr { +/// The contents of CResult_SiPrefixBolt11ParseErrorZ +pub union CResult_SiPrefixBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OpenChannel, + pub result: *mut crate::lightning_invoice::SiPrefix, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SiPrefixBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OpenChannelDecodeErrorZ { - /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either +pub struct CResult_SiPrefixBolt11ParseErrorZ { + /// The contents of this CResult_SiPrefixBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OpenChannelDecodeErrorZPtr, - /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub contents: CResult_SiPrefixBolt11ParseErrorZPtr, + /// Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15542,13 +19049,13 @@ pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } -impl Drop for CResult_OpenChannelDecodeErrorZ { +/// Frees any resources used by the CResult_SiPrefixBolt11ParseErrorZ. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_free(_res: CResult_SiPrefixBolt11ParseErrorZ) { } +impl Drop for CResult_SiPrefixBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15561,16 +19068,16 @@ impl Drop for CResult_OpenChannelDecodeErrorZ { } } } -impl From> for CResult_OpenChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SiPrefixBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OpenChannelDecodeErrorZPtr { result } + CResult_SiPrefixBolt11ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OpenChannelDecodeErrorZPtr { err } + CResult_SiPrefixBolt11ParseErrorZPtr { err } }; Self { contents, @@ -15578,59 +19085,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevokeAndACKDecodeErrorZ -pub union CResult_RevokeAndACKDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ +pub union CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::ParseOrSemanticError, } #[repr(C)] -/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevokeAndACKDecodeErrorZ { - /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceParseOrSemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevokeAndACKDecodeErrorZPtr, - /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15638,13 +19145,13 @@ pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } -impl Drop for CResult_RevokeAndACKDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceParseOrSemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res: CResult_Bolt11InvoiceParseOrSemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15657,16 +19164,16 @@ impl Drop for CResult_RevokeAndACKDecodeErrorZ { } } } -impl From> for CResult_RevokeAndACKDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceParseOrSemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RevokeAndACKDecodeErrorZPtr { result } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevokeAndACKDecodeErrorZPtr { err } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } }; Self { contents, @@ -15674,59 +19181,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownDecodeErrorZ -pub union CResult_ShutdownDecodeErrorZPtr { +/// The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ +pub union CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Shutdown, + pub result: *mut crate::lightning_invoice::SignedRawBolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SignedRawBolt11Invoice on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownDecodeErrorZ { - /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either +pub struct CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownDecodeErrorZPtr, - /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, + /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +} +#[no_mangle] +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SignedRawBolt11Invoice) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15734,13 +19241,13 @@ pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } -impl Drop for CResult_ShutdownDecodeErrorZ { +/// Frees any resources used by the CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) { } +impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15753,16 +19260,16 @@ impl Drop for CResult_ShutdownDecodeErrorZ { } } } -impl From> for CResult_ShutdownDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownDecodeErrorZPtr { result } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownDecodeErrorZPtr { err } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } }; Self { contents, @@ -15770,59 +19277,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailHTLCDecodeErrorZ -pub union CResult_UpdateFailHTLCDecodeErrorZPtr { +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + /// The element at position 0 + pub a: crate::lightning_invoice::RawBolt11Invoice, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, + /// The element at position 2 + pub c: crate::lightning_invoice::Bolt11InvoiceSignature, +} +impl From<(crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)> for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn from (tup: (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig: &C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a: crate::lightning_invoice::RawBolt11Invoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::Bolt11InvoiceSignature) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res: C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) { } +#[repr(C)] +/// The contents of CResult_PayeePubKeyErrorZ +pub union CResult_PayeePubKeyErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + pub result: *mut crate::lightning_invoice::PayeePubKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either +pub struct CResult_PayeePubKeyErrorZ { + /// The contents of this CResult_PayeePubKeyErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub contents: CResult_PayeePubKeyErrorZPtr, + /// Whether this CResult_PayeePubKeyErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeyErrorZ in the success state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeyErrorZ in the error state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15830,13 +19383,13 @@ pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PayeePubKeyErrorZ_is_ok(o: &CResult_PayeePubKeyErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_PayeePubKeyErrorZ. +pub extern "C" fn CResult_PayeePubKeyErrorZ_free(_res: CResult_PayeePubKeyErrorZ) { } +impl Drop for CResult_PayeePubKeyErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15849,16 +19402,16 @@ impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PayeePubKeyErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailHTLCDecodeErrorZPtr { result } + CResult_PayeePubKeyErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailHTLCDecodeErrorZPtr { err } + CResult_PayeePubKeyErrorZPtr { err } }; Self { contents, @@ -15866,59 +19419,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PayeePubKeyErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PayeePubKeyErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ -pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PrivateRouteZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_invoice::PrivateRoute, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PrivateRouteZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PrivateRouteZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } +impl Drop for CVec_PrivateRouteZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PrivateRouteZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_PositiveTimestampCreationErrorZ +pub union CResult_PositiveTimestampCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + pub result: *mut crate::lightning_invoice::PositiveTimestamp, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either +pub struct CResult_PositiveTimestampCreationErrorZ { + /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub contents: CResult_PositiveTimestampCreationErrorZPtr, + /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15926,13 +19525,13 @@ pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } +impl Drop for CResult_PositiveTimestampCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15945,16 +19544,16 @@ impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PositiveTimestampCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + CResult_PositiveTimestampCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + CResult_PositiveTimestampCreationErrorZPtr { err } }; Self { contents, @@ -15962,59 +19561,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFeeDecodeErrorZ -pub union CResult_UpdateFeeDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFee, +/// The contents of CResult_NoneBolt11SemanticErrorZ +pub union CResult_NoneBolt11SemanticErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFeeDecodeErrorZ { - /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either +pub struct CResult_NoneBolt11SemanticErrorZ { + /// The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFeeDecodeErrorZPtr, - /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub contents: CResult_NoneBolt11SemanticErrorZPtr, + /// Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_ok() -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16022,18 +19620,15 @@ pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } -impl Drop for CResult_UpdateFeeDecodeErrorZ { +/// Frees any resources used by the CResult_NoneBolt11SemanticErrorZ. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_free(_res: CResult_NoneBolt11SemanticErrorZ) { } +impl Drop for CResult_NoneBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -16041,16 +19636,16 @@ impl Drop for CResult_UpdateFeeDecodeErrorZ { } } } -impl From> for CResult_UpdateFeeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::Bolt11SemanticError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFeeDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneBolt11SemanticErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFeeDecodeErrorZPtr { err } + CResult_NoneBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -16058,59 +19653,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ -pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ +pub union CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceBolt11SemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16118,13 +19713,13 @@ pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceBolt11SemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res: CResult_Bolt11InvoiceBolt11SemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16137,16 +19732,16 @@ impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -16154,59 +19749,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateAddHTLCDecodeErrorZ -pub union CResult_UpdateAddHTLCDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_AddressZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Str, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_AddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_AddressZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } +impl Drop for CVec_AddressZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_AddressZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_DescriptionCreationErrorZ +pub union CResult_DescriptionCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + pub result: *mut crate::lightning_invoice::Description, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateAddHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either +pub struct CResult_DescriptionCreationErrorZ { + /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub contents: CResult_DescriptionCreationErrorZPtr, + /// Whether this CResult_DescriptionCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the success state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the error state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16214,13 +19855,13 @@ pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_DescriptionCreationErrorZ. +pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } +impl Drop for CResult_DescriptionCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16233,16 +19874,16 @@ impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateAddHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DescriptionCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateAddHTLCDecodeErrorZPtr { result } + CResult_DescriptionCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateAddHTLCDecodeErrorZPtr { err } + CResult_DescriptionCreationErrorZPtr { err } }; Self { contents, @@ -16250,59 +19891,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OnionMessageDecodeErrorZ -pub union CResult_OnionMessageDecodeErrorZPtr { +/// The contents of CResult_PrivateRouteCreationErrorZ +pub union CResult_PrivateRouteCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OnionMessage, + pub result: *mut crate::lightning_invoice::PrivateRoute, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OnionMessageDecodeErrorZ { - /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either +pub struct CResult_PrivateRouteCreationErrorZ { + /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OnionMessageDecodeErrorZPtr, - /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + pub contents: CResult_PrivateRouteCreationErrorZPtr, + /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16310,13 +19951,13 @@ pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } -impl Drop for CResult_OnionMessageDecodeErrorZ { +/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } +impl Drop for CResult_PrivateRouteCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16329,16 +19970,16 @@ impl Drop for CResult_OnionMessageDecodeErrorZ { } } } -impl From> for CResult_OnionMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PrivateRouteCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OnionMessageDecodeErrorZPtr { result } + CResult_PrivateRouteCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OnionMessageDecodeErrorZPtr { err } + CResult_PrivateRouteCreationErrorZPtr { err } }; Self { contents, @@ -16346,59 +19987,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PingDecodeErrorZ -pub union CResult_PingDecodeErrorZPtr { +/// The contents of CResult_OutPointDecodeErrorZ +pub union CResult_OutPointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Ping, + pub result: *mut crate::lightning::chain::transaction::OutPoint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PingDecodeErrorZ { - /// The contents of this CResult_PingDecodeErrorZ, accessible via either +pub struct CResult_OutPointDecodeErrorZ { + /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PingDecodeErrorZPtr, - /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub contents: CResult_OutPointDecodeErrorZPtr, + /// Whether this CResult_OutPointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the success state. -pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the error state. -pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16406,13 +20047,13 @@ pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PingDecodeErrorZ. -pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } -impl Drop for CResult_PingDecodeErrorZ { +/// Frees any resources used by the CResult_OutPointDecodeErrorZ. +pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } +impl Drop for CResult_OutPointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16425,16 +20066,16 @@ impl Drop for CResult_PingDecodeErrorZ { } } } -impl From> for CResult_PingDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutPointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PingDecodeErrorZPtr { result } + CResult_OutPointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PingDecodeErrorZPtr { err } + CResult_OutPointDecodeErrorZPtr { err } }; Self { contents, @@ -16442,59 +20083,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PongDecodeErrorZ -pub union CResult_PongDecodeErrorZPtr { +/// The contents of CResult_BigSizeDecodeErrorZ +pub union CResult_BigSizeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Pong, + pub result: *mut crate::lightning::util::ser::BigSize, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BigSizeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::BigSize on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PongDecodeErrorZ { - /// The contents of this CResult_PongDecodeErrorZ, accessible via either +pub struct CResult_BigSizeDecodeErrorZ { + /// The contents of this CResult_BigSizeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PongDecodeErrorZPtr, - /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub contents: CResult_BigSizeDecodeErrorZPtr, + /// Whether this CResult_BigSizeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the success state. -pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the success state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_ok(o: crate::lightning::util::ser::BigSize) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the error state. -pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the error state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16502,13 +20143,13 @@ pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PongDecodeErrorZ. -pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } -impl Drop for CResult_PongDecodeErrorZ { +/// Frees any resources used by the CResult_BigSizeDecodeErrorZ. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_free(_res: CResult_BigSizeDecodeErrorZ) { } +impl Drop for CResult_BigSizeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16521,16 +20162,16 @@ impl Drop for CResult_PongDecodeErrorZ { } } } -impl From> for CResult_PongDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BigSizeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PongDecodeErrorZPtr { result } + CResult_BigSizeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PongDecodeErrorZPtr { err } + CResult_BigSizeDecodeErrorZPtr { err } }; Self { contents, @@ -16538,59 +20179,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BigSizeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BigSizeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BigSizeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ -pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_HostnameDecodeErrorZ +pub union CResult_HostnameDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, + pub result: *mut crate::lightning::util::ser::Hostname, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HostnameDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::Hostname on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_HostnameDecodeErrorZ { + /// The contents of this CResult_HostnameDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_HostnameDecodeErrorZPtr, + /// Whether this CResult_HostnameDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the success state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_ok(o: crate::lightning::util::ser::Hostname) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the error state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16598,13 +20239,13 @@ pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HostnameDecodeErrorZ_is_ok(o: &CResult_HostnameDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_HostnameDecodeErrorZ. +pub extern "C" fn CResult_HostnameDecodeErrorZ_free(_res: CResult_HostnameDecodeErrorZ) { } +impl Drop for CResult_HostnameDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16617,16 +20258,16 @@ impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HostnameDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + CResult_HostnameDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + CResult_HostnameDecodeErrorZPtr { err } }; Self { contents, @@ -16634,95 +20275,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HostnameDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelAnnouncementDecodeErrorZ -pub union CResult_ChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedNoneZ +pub union CResult_TransactionU16LenLimitedNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedNoneZ { + /// The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedNoneZPtr, + /// Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_err() -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_is_ok(o: &CResult_TransactionU16LenLimitedNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_free(_res: CResult_TransactionU16LenLimitedNoneZ) { } +impl Drop for CResult_TransactionU16LenLimitedNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelAnnouncementDecodeErrorZPtr { result } + CResult_TransactionU16LenLimitedNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TransactionU16LenLimitedNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -16730,59 +20367,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ -pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedDecodeErrorZ +pub union CResult_TransactionU16LenLimitedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionU16LenLimitedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedDecodeErrorZ { + /// The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr, + /// Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16790,13 +20427,13 @@ pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res: CResult_TransactionU16LenLimitedDecodeErrorZ) { } +impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16809,16 +20446,16 @@ impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } }; Self { contents, @@ -16826,59 +20463,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelUpdateDecodeErrorZ -pub union CResult_ChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_UntrustedStringDecodeErrorZ +pub union CResult_UntrustedStringDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, + pub result: *mut crate::lightning::util::string::UntrustedString, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_UntrustedStringDecodeErrorZ { + /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_UntrustedStringDecodeErrorZPtr, + /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16886,13 +20523,13 @@ pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } +impl Drop for CResult_UntrustedStringDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16905,16 +20542,16 @@ impl Drop for CResult_ChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UntrustedStringDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelUpdateDecodeErrorZPtr { result } + CResult_UntrustedStringDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelUpdateDecodeErrorZPtr { err } + CResult_UntrustedStringDecodeErrorZPtr { err } }; Self { contents, @@ -16922,59 +20559,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ErrorMessageDecodeErrorZ -pub union CResult_ErrorMessageDecodeErrorZPtr { +/// The contents of CResult_PaymentIdPaymentErrorZ +pub union CResult_PaymentIdPaymentErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ErrorMessage, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::payment::PaymentError, } #[repr(C)] -/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ErrorMessageDecodeErrorZ { - /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either +pub struct CResult_PaymentIdPaymentErrorZ { + /// The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ErrorMessageDecodeErrorZPtr, - /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub contents: CResult_PaymentIdPaymentErrorZPtr, + /// Whether this CResult_PaymentIdPaymentErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_PaymentIdPaymentErrorZ in the success state. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentIdPaymentErrorZ { + CResult_PaymentIdPaymentErrorZ { + contents: CResult_PaymentIdPaymentErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_PaymentIdPaymentErrorZ in the error state. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_PaymentIdPaymentErrorZ { + CResult_PaymentIdPaymentErrorZ { + contents: CResult_PaymentIdPaymentErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16982,13 +20619,13 @@ pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_is_ok(o: &CResult_PaymentIdPaymentErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } -impl Drop for CResult_ErrorMessageDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentIdPaymentErrorZ. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_free(_res: CResult_PaymentIdPaymentErrorZ) { } +impl Drop for CResult_PaymentIdPaymentErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17001,16 +20638,16 @@ impl Drop for CResult_ErrorMessageDecodeErrorZ { } } } -impl From> for CResult_ErrorMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentIdPaymentErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ErrorMessageDecodeErrorZPtr { result } + CResult_PaymentIdPaymentErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ErrorMessageDecodeErrorZPtr { err } + CResult_PaymentIdPaymentErrorZPtr { err } }; Self { contents, @@ -17018,59 +20655,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentIdPaymentErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentIdPaymentErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_clone(orig: &CResult_PaymentIdPaymentErrorZ) -> CResult_PaymentIdPaymentErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WarningMessageDecodeErrorZ -pub union CResult_WarningMessageDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::WarningMessage, +/// The contents of CResult_NonePaymentErrorZ +pub union CResult_NonePaymentErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::payment::PaymentError, } #[repr(C)] -/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NonePaymentErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WarningMessageDecodeErrorZ { - /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either +pub struct CResult_NonePaymentErrorZ { + /// The contents of this CResult_NonePaymentErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WarningMessageDecodeErrorZPtr, - /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + pub contents: CResult_NonePaymentErrorZPtr, + /// Whether this CResult_NonePaymentErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePaymentErrorZ in the success state. +pub extern "C" fn CResult_NonePaymentErrorZ_ok() -> CResult_NonePaymentErrorZ { + CResult_NonePaymentErrorZ { + contents: CResult_NonePaymentErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { +/// Creates a new CResult_NonePaymentErrorZ in the error state. +pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_NonePaymentErrorZ { + CResult_NonePaymentErrorZ { + contents: CResult_NonePaymentErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17078,18 +20714,15 @@ pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NonePaymentErrorZ_is_ok(o: &CResult_NonePaymentErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } -impl Drop for CResult_WarningMessageDecodeErrorZ { +/// Frees any resources used by the CResult_NonePaymentErrorZ. +pub extern "C" fn CResult_NonePaymentErrorZ_free(_res: CResult_NonePaymentErrorZ) { } +impl Drop for CResult_NonePaymentErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -17097,16 +20730,16 @@ impl Drop for CResult_WarningMessageDecodeErrorZ { } } } -impl From> for CResult_WarningMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::payment::PaymentError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WarningMessageDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePaymentErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WarningMessageDecodeErrorZPtr { err } + CResult_NonePaymentErrorZPtr { err } }; Self { contents, @@ -17114,59 +20747,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePaymentErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePaymentErrorZ_clone(orig: &CResult_NonePaymentErrorZ) -> CResult_NonePaymentErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ -pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_StringErrorZ +pub union CResult_StringErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, + pub result: *mut crate::c_types::Str, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_StringErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_StringErrorZ { + /// The contents of this CResult_StringErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_StringErrorZPtr, + /// Whether this CResult_StringErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_StringErrorZ in the success state. +pub extern "C" fn CResult_StringErrorZ_ok(o: crate::c_types::Str) -> CResult_StringErrorZ { + CResult_StringErrorZ { + contents: CResult_StringErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_StringErrorZ in the error state. +pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StringErrorZ { + CResult_StringErrorZ { + contents: CResult_StringErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17174,13 +20807,13 @@ pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_StringErrorZ_is_ok(o: &CResult_StringErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_StringErrorZ. +pub extern "C" fn CResult_StringErrorZ_free(_res: CResult_StringErrorZ) { } +impl Drop for CResult_StringErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17193,16 +20826,16 @@ impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_StringErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + CResult_StringErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + CResult_StringErrorZPtr { err } }; Self { contents, @@ -17210,59 +20843,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_StringErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_StringErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_StringErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeAnnouncementDecodeErrorZ -pub union CResult_NodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TxOutUtxoLookupErrorZ +pub union CResult_TxOutUtxoLookupErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, + pub result: *mut crate::c_types::TxOut, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, } #[repr(C)] -/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TxOutUtxoLookupErrorZ { + /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TxOutUtxoLookupErrorZPtr, + /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17270,13 +20903,13 @@ pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } +impl Drop for CResult_TxOutUtxoLookupErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17289,16 +20922,16 @@ impl Drop for CResult_NodeAnnouncementDecodeErrorZ { } } } -impl From> for CResult_NodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxOutUtxoLookupErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeAnnouncementDecodeErrorZPtr { result } + CResult_TxOutUtxoLookupErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeAnnouncementDecodeErrorZPtr { err } + CResult_TxOutUtxoLookupErrorZPtr { err } }; Self { contents, @@ -17306,95 +20939,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ -pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// The contents of CResult_OnionMessagePathNoneZ +pub union CResult_OnionMessagePathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::onion_message::messenger::OnionMessagePath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OnionMessagePathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::OnionMessagePath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryShortChannelIdsDecodeErrorZ { - /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either +pub struct CResult_OnionMessagePathNoneZ { + /// The contents of this CResult_OnionMessagePathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, - /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + pub contents: CResult_OnionMessagePathNoneZPtr, + /// Whether this CResult_OnionMessagePathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// Creates a new CResult_OnionMessagePathNoneZ in the success state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_ok(o: crate::lightning::onion_message::messenger::OnionMessagePath) -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_OnionMessagePathNoneZ in the error state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_err() -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OnionMessagePathNoneZ_is_ok(o: &CResult_OnionMessagePathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } -impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { +/// Frees any resources used by the CResult_OnionMessagePathNoneZ. +pub extern "C" fn CResult_OnionMessagePathNoneZ_free(_res: CResult_OnionMessagePathNoneZ) { } +impl Drop for CResult_OnionMessagePathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OnionMessagePathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryShortChannelIdsDecodeErrorZPtr { result } + CResult_OnionMessagePathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryShortChannelIdsDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_OnionMessagePathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -17402,59 +21031,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OnionMessagePathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OnionMessagePathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OnionMessagePathNoneZ_clone(orig: &CResult_OnionMessagePathNoneZ) -> CResult_OnionMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ -pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, +/// The contents of CResult_NoneSendErrorZ +pub union CResult_NoneSendErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[repr(C)] -/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneSendErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { - /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either +pub struct CResult_NoneSendErrorZ { + /// The contents of this CResult_NoneSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, - /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + pub contents: CResult_NoneSendErrorZPtr, + /// Whether this CResult_NoneSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneSendErrorZ in the success state. +pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +/// Creates a new CResult_NoneSendErrorZ in the error state. +pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17462,18 +21090,15 @@ pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } -impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { +/// Frees any resources used by the CResult_NoneSendErrorZ. +pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { } +impl Drop for CResult_NoneSendErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -17481,16 +21106,16 @@ impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { } } } -impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } + CResult_NoneSendErrorZPtr { err } }; Self { contents, @@ -17498,95 +21123,74 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_QueryChannelRangeDecodeErrorZ -pub union CResult_QueryChannelRangeDecodeErrorZPtr { +/// The contents of CResult_BlindedPathNoneZ +pub union CResult_BlindedPathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::blinded_path::BlindedPath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryChannelRangeDecodeErrorZ { - /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_BlindedPathNoneZ { + /// The contents of this CResult_BlindedPathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, - /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_BlindedPathNoneZPtr, + /// Whether this CResult_BlindedPathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathNoneZ in the success state. +pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { + CResult_BlindedPathNoneZ { + contents: CResult_BlindedPathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_BlindedPathNoneZ in the error state. +pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { + CResult_BlindedPathNoneZ { + contents: CResult_BlindedPathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } -impl Drop for CResult_QueryChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedPathNoneZ. +pub extern "C" fn CResult_BlindedPathNoneZ_free(_res: CResult_BlindedPathNoneZ) { } +impl Drop for CResult_BlindedPathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_QueryChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedPathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryChannelRangeDecodeErrorZPtr { result } + CResult_BlindedPathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryChannelRangeDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -17594,59 +21198,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyChannelRangeDecodeErrorZ -pub union CResult_ReplyChannelRangeDecodeErrorZPtr { +/// The contents of CResult_BlindedPathDecodeErrorZ +pub union CResult_BlindedPathDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, + pub result: *mut crate::lightning::blinded_path::BlindedPath, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyChannelRangeDecodeErrorZ { - /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_BlindedPathDecodeErrorZ { + /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, - /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_BlindedPathDecodeErrorZPtr, + /// Whether this CResult_BlindedPathDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { + CResult_BlindedPathDecodeErrorZ { + contents: CResult_BlindedPathDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { + CResult_BlindedPathDecodeErrorZ { + contents: CResult_BlindedPathDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17654,13 +21258,13 @@ pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } -impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedPathDecodeErrorZ. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_free(_res: CResult_BlindedPathDecodeErrorZ) { } +impl Drop for CResult_BlindedPathDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17672,17 +21276,17 @@ impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { } } } -} -impl From> for CResult_ReplyChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +} +impl From> for CResult_BlindedPathDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyChannelRangeDecodeErrorZPtr { result } + CResult_BlindedPathDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyChannelRangeDecodeErrorZPtr { err } + CResult_BlindedPathDecodeErrorZPtr { err } }; Self { contents, @@ -17690,59 +21294,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPathDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_GossipTimestampFilterDecodeErrorZ -pub union CResult_GossipTimestampFilterDecodeErrorZPtr { +/// The contents of CResult_BlindedHopDecodeErrorZ +pub union CResult_BlindedHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, + pub result: *mut crate::lightning::blinded_path::BlindedHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_GossipTimestampFilterDecodeErrorZ { - /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either +pub struct CResult_BlindedHopDecodeErrorZ { + /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, - /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + pub contents: CResult_BlindedHopDecodeErrorZPtr, + /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17750,13 +21354,13 @@ pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } -impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } +impl Drop for CResult_BlindedHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17769,16 +21373,16 @@ impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { } } } -impl From> for CResult_GossipTimestampFilterDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_GossipTimestampFilterDecodeErrorZPtr { result } + CResult_BlindedHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_GossipTimestampFilterDecodeErrorZPtr { err } + CResult_BlindedHopDecodeErrorZPtr { err } }; Self { contents, @@ -17786,105 +21390,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PhantomRouteHintsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PhantomRouteHintsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PhantomRouteHintsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } -impl Drop for CVec_PhantomRouteHintsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PhantomRouteHintsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceSignOrCreationErrorZ -pub union CResult_InvoiceSignOrCreationErrorZPtr { +/// The contents of CResult_InvoiceErrorDecodeErrorZ +pub union CResult_InvoiceErrorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::offers::invoice_error::InvoiceError, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SignOrCreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceSignOrCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. +/// A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceSignOrCreationErrorZ { - /// The contents of this CResult_InvoiceSignOrCreationErrorZ, accessible via either +pub struct CResult_InvoiceErrorDecodeErrorZ { + /// The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceSignOrCreationErrorZPtr, - /// Whether this CResult_InvoiceSignOrCreationErrorZ represents a success state. + pub contents: CResult_InvoiceErrorDecodeErrorZPtr, + /// Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceSignOrCreationErrorZ { - CResult_InvoiceSignOrCreationErrorZ { - contents: CResult_InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_ok(o: crate::lightning::offers::invoice_error::InvoiceError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_InvoiceSignOrCreationErrorZ { - CResult_InvoiceSignOrCreationErrorZ { - contents: CResult_InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17892,13 +21450,13 @@ pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_err(e: crate::lightning_in } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_InvoiceSignOrCreationErrorZ) -> bool { +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_is_ok(o: &CResult_InvoiceErrorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_free(_res: CResult_InvoiceSignOrCreationErrorZ) { } -impl Drop for CResult_InvoiceSignOrCreationErrorZ { +/// Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_free(_res: CResult_InvoiceErrorDecodeErrorZ) { } +impl Drop for CResult_InvoiceErrorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17911,16 +21469,16 @@ impl Drop for CResult_InvoiceSignOrCreationErrorZ { } } } -impl From> for CResult_InvoiceSignOrCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InvoiceErrorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceSignOrCreationErrorZPtr { result } + CResult_InvoiceErrorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceSignOrCreationErrorZPtr { err } + CResult_InvoiceErrorDecodeErrorZPtr { err } }; Self { contents, @@ -17928,69 +21486,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceSignOrCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InvoiceErrorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceSignOrCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InvoiceErrorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_clone(orig: &CResult_InvoiceSignOrCreationErrorZ) -> CResult_InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_FutureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::util::wakers::Future, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_FutureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_FutureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } -impl Drop for CVec_FutureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_FutureZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// An enum which can either contain a crate::lightning::chain::Filter or not pub enum COption_FilterZ { @@ -18278,82 +21790,3 @@ impl Clone for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { Self::from(res) } } -#[repr(C)] -/// The contents of CResult_u32GraphSyncErrorZ -pub union CResult_u32GraphSyncErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut u32, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, -} -#[repr(C)] -/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, -/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_u32GraphSyncErrorZ { - /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_u32GraphSyncErrorZPtr, - /// Whether this CResult_u32GraphSyncErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the success state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the error state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_u32GraphSyncErrorZ. -pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } -impl Drop for CResult_u32GraphSyncErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_u32GraphSyncErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_u32GraphSyncErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_u32GraphSyncErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} diff --git a/lightning-c-bindings/src/lightning/blinded_path.rs b/lightning-c-bindings/src/lightning/blinded_path.rs index febf222..1972ae8 100644 --- a/lightning-c-bindings/src/lightning/blinded_path.rs +++ b/lightning-c-bindings/src/lightning/blinded_path.rs @@ -213,7 +213,7 @@ pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool { /// Errors if less than two hops are provided or if `node_pk`(s) are invalid. #[must_use] #[no_mangle] -pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { +pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); }; let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 687262b..e27203a 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -26,8 +26,20 @@ pub struct BroadcasterInterface { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Sends a transaction out to (hopefully) be mined. - pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction), + /// Sends a list of transactions out to (hopefully) be mined. + /// This only needs to handle the actual broadcasting of transactions, LDK will automatically + /// rebroadcast transactions that haven't made it into a block. + /// + /// In some cases LDK may attempt to broadcast a transaction which double-spends another + /// and this isn't a bug and can be safely ignored. + /// + /// If more than one transaction is given, these transactions should be considered to be a + /// package and broadcast together. Some of the transactions may or may not depend on each other, + /// be sure to manage both cases correctly. + /// + /// Bitcoin transaction packages are defined in BIP 331 and here: + /// https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md + pub broadcast_transactions: extern "C" fn (this_arg: *const c_void, txs: crate::c_types::derived::CVec_TransactionZ), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -38,15 +50,16 @@ unsafe impl Sync for BroadcasterInterface {} pub(crate) extern "C" fn BroadcasterInterface_clone_fields(orig: &BroadcasterInterface) -> BroadcasterInterface { BroadcasterInterface { this_arg: orig.this_arg, - broadcast_transaction: Clone::clone(&orig.broadcast_transaction), + broadcast_transactions: Clone::clone(&orig.broadcast_transactions), free: Clone::clone(&orig.free), } } use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface; impl rustBroadcasterInterface for BroadcasterInterface { - fn broadcast_transaction(&self, mut tx: &bitcoin::blockdata::transaction::Transaction) { - (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(tx)) + fn broadcast_transactions(&self, mut txs: &[&bitcoin::blockdata::transaction::Transaction]) { + let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); }; + (self.broadcast_transactions)(self.this_arg, local_txs.into()) } } @@ -68,17 +81,26 @@ impl Drop for BroadcasterInterface { } } } -/// An enum that represents the speed at which we want a transaction to confirm used for feerate +/// An enum that represents the priority at which we want a transaction to confirm used for feerate /// estimation. #[derive(Clone)] #[must_use] #[repr(C)] pub enum ConfirmationTarget { - /// We are happy with this transaction confirming slowly when feerate drops some. + /// We'd like a transaction to confirm in the future, but don't want to commit most of the fees + /// required to do so yet. The remaining fees will come via a Child-Pays-For-Parent (CPFP) fee + /// bump of the transaction. + /// + /// The feerate returned should be the absolute minimum feerate required to enter most node + /// mempools across the network. Note that if you are not able to obtain this feerate estimate, + /// you should likely use the furthest-out estimate allowed by your fee estimator. + MempoolMinimum, + /// We are happy with a transaction confirming slowly, at least within a day or so worth of + /// blocks. Background, - /// We'd like this transaction to confirm without major delay, but 12-18 blocks is fine. + /// We'd like a transaction to confirm without major delayed, i.e., within the next 12-24 blocks. Normal, - /// We'd like this transaction to confirm in the next few blocks. + /// We'd like a transaction to confirm in the next few blocks. HighPriority, } use lightning::chain::chaininterface::ConfirmationTarget as ConfirmationTargetImport; @@ -88,6 +110,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeConfirmationTarget { match self { + ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum, ConfirmationTarget::Background => nativeConfirmationTarget::Background, ConfirmationTarget::Normal => nativeConfirmationTarget::Normal, ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority, @@ -96,6 +119,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn into_native(self) -> nativeConfirmationTarget { match self { + ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum, ConfirmationTarget::Background => nativeConfirmationTarget::Background, ConfirmationTarget::Normal => nativeConfirmationTarget::Normal, ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority, @@ -104,6 +128,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn from_native(native: &nativeConfirmationTarget) -> Self { match native { + nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum, nativeConfirmationTarget::Background => ConfirmationTarget::Background, nativeConfirmationTarget::Normal => ConfirmationTarget::Normal, nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority, @@ -112,6 +137,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self { match native { + nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum, nativeConfirmationTarget::Background => ConfirmationTarget::Background, nativeConfirmationTarget::Normal => ConfirmationTarget::Normal, nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority, @@ -124,6 +150,10 @@ pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> Confirm orig.clone() } #[no_mangle] +/// Utility method to constructs a new MempoolMinimum-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_mempool_minimum() -> ConfirmationTarget { + ConfirmationTarget::MempoolMinimum} +#[no_mangle] /// Utility method to constructs a new Background-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_background() -> ConfirmationTarget { ConfirmationTarget::Background} @@ -153,6 +183,11 @@ pub extern "C" fn ConfirmationTarget_eq(a: &ConfirmationTarget, b: &Confirmation /// A trait which should be implemented to provide feerate information on a number of time /// horizons. /// +/// If access to a local mempool is not feasible, feerate estimates should be fetched from a set of +/// third-parties hosting them. Note that this enables them to affect the propagation of your +/// pre-signed transactions at any time and therefore endangers the safety of channels funds. It +/// should be considered carefully as a deployment. +/// /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're /// called from inside the library in response to chain events, P2P events, or timer events). #[repr(C)] @@ -168,7 +203,6 @@ pub struct FeeEstimator { /// The following unit conversions can be used to convert to sats/KW: /// * satoshis-per-byte * 250 /// * satoshis-per-kbyte / 4 - #[must_use] pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: crate::lightning::chain::chaininterface::ConfirmationTarget) -> u32, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index f6a97a3..4bdccab 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -159,7 +159,6 @@ pub struct Persist { /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`Writeable::write`]: crate::util::ser::Writeable::write - #[must_use] pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Update one channel's data. The provided [`ChannelMonitor`] has already applied the given /// update. @@ -196,7 +195,6 @@ pub struct Persist { /// [`Writeable::write`]: crate::util::ser::Writeable::write /// /// Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -215,12 +213,12 @@ pub(crate) extern "C" fn Persist_clone_fields(orig: &Persist) -> Persist { } use lightning::chain::chainmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { +impl rustPersist for Persist { + fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); ret.into_native() } - fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { + fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { let mut local_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, local_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); ret.into_native() @@ -247,7 +245,7 @@ impl Drop for Persist { } use lightning::chain::chainmonitor::LockedChannelMonitor as nativeLockedChannelMonitorImport; -pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner>; +pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::WriteableEcdsaChannelSigner>; /// A read-only reference to a current ChannelMonitor. /// @@ -301,7 +299,7 @@ impl LockedChannelMonitor { } use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; -pub(crate) type nativeChainMonitor = nativeChainMonitorImport; +pub(crate) type nativeChainMonitor = nativeChainMonitorImport; /// An implementation of [`chain::Watch`] for monitoring channels. /// @@ -547,9 +545,9 @@ extern "C" fn ChainMonitor_Confirm_best_block_updated(this_arg: *const c_void, h >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] -extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index dbe2932..276fcda 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -525,6 +525,10 @@ pub enum Balance { /// The height at which the counterparty may be able to claim the balance if we have not /// done so. timeout_height: u32, + /// The payment hash that locks this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The preimage that can be used to claim this HTLC. + payment_preimage: crate::c_types::ThirtyTwoBytes, }, /// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain /// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat @@ -536,6 +540,8 @@ pub enum Balance { /// The height at which we will be able to claim the balance if our counterparty has not /// done so. claimable_height: u32, + /// The payment hash whose preimage our counterparty needs to claim this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, }, /// HTLCs which we received from our counterparty which are claimable with a preimage which we /// do not currently have. This will only be claimable if we receive the preimage from the node @@ -547,6 +553,8 @@ pub enum Balance { /// The height at which our counterparty will be able to claim the balance if we have not /// yet received the preimage and claimed it ourselves. expiry_height: u32, + /// The payment hash whose preimage we need to claim this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, }, /// The channel has been closed, and our counterparty broadcasted a revoked commitment /// transaction. @@ -582,28 +590,36 @@ impl Balance { confirmation_height: confirmation_height_nonref, } }, - Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => { + Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut timeout_height_nonref = Clone::clone(timeout_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_preimage_nonref = Clone::clone(payment_preimage); nativeBalance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis_nonref, timeout_height: timeout_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), } }, - Balance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => { + Balance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); nativeBalance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, claimable_height: claimable_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), } }, - Balance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => { + Balance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut expiry_height_nonref = Clone::clone(expiry_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); nativeBalance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, expiry_height: expiry_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), } }, Balance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => { @@ -628,22 +644,26 @@ impl Balance { confirmation_height: confirmation_height, } }, - Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => { + Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { nativeBalance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis, timeout_height: timeout_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), } }, - Balance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => { + Balance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, mut payment_hash, } => { nativeBalance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, claimable_height: claimable_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), } }, - Balance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => { + Balance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, mut payment_hash, } => { nativeBalance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, expiry_height: expiry_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), } }, Balance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => { @@ -670,28 +690,36 @@ impl Balance { confirmation_height: confirmation_height_nonref, } }, - nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => { + nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut timeout_height_nonref = Clone::clone(timeout_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_preimage_nonref = Clone::clone(payment_preimage); Balance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis_nonref, timeout_height: timeout_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, claimable_height: claimable_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, } }, - nativeBalance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => { + nativeBalance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut expiry_height_nonref = Clone::clone(expiry_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, expiry_height: expiry_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, } }, nativeBalance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => { @@ -716,22 +744,26 @@ impl Balance { confirmation_height: confirmation_height, } }, - nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => { + nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { Balance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis, timeout_height: timeout_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, mut payment_hash, } => { Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, claimable_height: claimable_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, } }, - nativeBalance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => { + nativeBalance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, mut payment_hash, } => { Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, expiry_height: expiry_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, } }, nativeBalance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => { @@ -767,26 +799,30 @@ pub extern "C" fn Balance_claimable_awaiting_confirmations(claimable_amount_sato } #[no_mangle] /// Utility method to constructs a new ContentiousClaimable-variant Balance -pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32) -> Balance { +pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::ContentiousClaimable { claimable_amount_satoshis, timeout_height, + payment_hash, + payment_preimage, } } #[no_mangle] /// Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance { +pub extern "C" fn Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis, claimable_height, + payment_hash, } } #[no_mangle] /// Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis: u64, expiry_height: u32) -> Balance { +pub extern "C" fn Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis: u64, expiry_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis, expiry_height, + payment_hash, } } #[no_mangle] @@ -802,9 +838,22 @@ pub extern "C" fn Balance_counterparty_revoked_output_claimable(claimable_amount pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } +/// The amount claimable, in satoshis. This excludes balances that we are unsure if we are able +/// to claim, this is because we are waiting for a preimage or for a timeout to expire. For more +/// information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and +/// [`Balance::MaybePreimageClaimableHTLC`]. +/// +/// On-chain fees required to claim the balance are not included in this amount. +#[must_use] +#[no_mangle] +pub extern "C" fn Balance_claimable_amount_satoshis(this_arg: &crate::lightning::chain::channelmonitor::Balance) -> u64 { + let mut ret = this_arg.to_native().claimable_amount_satoshis(); + ret +} + use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; +pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates /// on-chain transactions to ensure no loss of funds occurs. @@ -812,11 +861,6 @@ pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport crate::c_types::derived::CVec_EventZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_pending_events(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::Event::native_into(item) }); }; - local_ret.into() +pub extern "C" fn ChannelMonitor_process_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, handler: &crate::lightning::events::EventHandler) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_events(handler) } /// Gets the `node_id` of the counterparty for this channel. @@ -1004,7 +1050,7 @@ pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &cra pub extern "C" fn ChannelMonitor_block_connected(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -1027,7 +1073,7 @@ pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &crate::lightning: pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -1053,16 +1099,16 @@ pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &crate::light #[no_mangle] pub extern "C" fn ChannelMonitor_best_block_updated(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.best_block_updated(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } /// Returns the set of txids that should be monitored for re-organization out of the chain. #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } @@ -1110,11 +1156,11 @@ pub extern "C" fn ChannelMonitor_get_claimable_balances(this_arg: &crate::lightn #[no_mangle] /// Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg_a: &crate::lightning::chain::keysinterface::EntropySource, arg_b: &crate::lightning::chain::keysinterface::SignerProvider) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg_a: &crate::lightning::sign::EntropySource, arg_b: &crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { let arg_a_conv = arg_a; let arg_b_conv = arg_b; let arg_conv = (arg_a_conv, arg_b_conv); - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs deleted file mode 100644 index acfb440..0000000 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ /dev/null @@ -1,2485 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Provides keys to LDK and defines some useful objects describing spendable on-chain outputs. -//! -//! The provided output descriptors follow a custom LDK data format and are currently not fully -//! compatible with Bitcoin Core output descriptors. - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - - -use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport; -pub(crate) type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport; - -/// Information about a spendable output to a P2WSH script. -/// -/// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct DelayedPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeDelayedPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DelayedPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor) }; -} -#[allow(unused)] -impl DelayedPaymentOutputDescriptor { - pub(crate) fn get_native_ref(&self) -> &'static nativeDelayedPaymentOutputDescriptor { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDelayedPaymentOutputDescriptor { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Per commitment point to derive the delayed payment key by key holder. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Per commitment point to derive the delayed payment key by key holder. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust(); -} -/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; - *inner_val -} -/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; -} -/// The output which is referenced by the given outpoint. -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_output(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::TxOut { - let mut inner_val = this_ptr.get_native_mut_ref().output.clone(); - crate::c_types::TxOut::from_rust(inner_val) -} -/// The output which is referenced by the given outpoint. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_pubkey = val.into_rust(); -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; - inner_val -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; - *inner_val -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; -} -/// Constructs a new DelayedPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { - DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeDelayedPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - per_commitment_point: per_commitment_point_arg.into_rust(), - to_self_delay: to_self_delay_arg, - output: output_arg.into_rust(), - revocation_pubkey: revocation_pubkey_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - }), is_owned: true } -} -impl Clone for DelayedPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DelayedPaymentOutputDescriptor -pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor { - orig.clone() -} -/// Checks if two DelayedPaymentOutputDescriptors 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. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_eq(a: &DelayedPaymentOutputDescriptor, b: &DelayedPaymentOutputDescriptor) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -#[no_mangle] -/// Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read -pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentOutputDescriptor) }) -} -#[no_mangle] -/// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write -pub extern "C" fn DelayedPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} - -use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport; -pub(crate) type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport; - -/// Information about a spendable output to our \"payment key\". -/// -/// See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct StaticPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeStaticPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for StaticPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor) }; -} -#[allow(unused)] -impl StaticPaymentOutputDescriptor { - pub(crate) fn get_native_ref(&self) -> &'static nativeStaticPaymentOutputDescriptor { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStaticPaymentOutputDescriptor { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The output which is referenced by the given outpoint. -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_output(this_ptr: &StaticPaymentOutputDescriptor) -> crate::c_types::TxOut { - let mut inner_val = this_ptr.get_native_mut_ref().output.clone(); - crate::c_types::TxOut::from_rust(inner_val) -} -/// The output which is referenced by the given outpoint. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; - inner_val -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; - *inner_val -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; -} -/// Constructs a new StaticPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor { - StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeStaticPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - output: output_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - }), is_owned: true } -} -impl Clone for StaticPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the StaticPaymentOutputDescriptor -pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor { - orig.clone() -} -/// Checks if two StaticPaymentOutputDescriptors 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. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_eq(a: &StaticPaymentOutputDescriptor, b: &StaticPaymentOutputDescriptor) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -#[no_mangle] -/// Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read -pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStaticPaymentOutputDescriptor) }) -} -#[no_mangle] -/// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write -pub extern "C" fn StaticPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// Describes the necessary information to spend a spendable output. -/// -/// When on-chain outputs are created by LDK (which our counterparty is not able to claim at any -/// point in the future) a [`SpendableOutputs`] event is generated which you must track and be able -/// to spend on-chain. The information needed to do this is provided in this enum, including the -/// outpoint describing which `txid` and output `index` is available, the full output which exists -/// at that `txid`/`index`, and any keys or other information required to sign. -/// -/// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum SpendableOutputDescriptor { - /// An output to a script which was provided via [`SignerProvider`] directly, either from - /// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already - /// know how to spend it. No secret keys are provided as LDK was never given any key. - /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC - /// on-chain using the payment preimage or after it has timed out. - /// - /// [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey - /// [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey - StaticOutput { - /// The outpoint which is spendable. - outpoint: crate::lightning::chain::transaction::OutPoint, - /// The output which is referenced by the given outpoint. - output: crate::c_types::TxOut, - }, - /// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` - /// delay. - /// - /// The witness in the spending input should be: - /// ```bitcoin - /// (MINIMALIF standard rule) - /// ``` - /// - /// Note that the `nSequence` field in the spending input must be set to - /// [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not - /// broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after - /// the outpoint confirms, see [BIP - /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK - /// won't generate a [`SpendableOutputDescriptor`] until the corresponding block height - /// is reached. - /// - /// These are generally the result of a \"revocable\" output to us, spendable only by us unless - /// it is an output from an old state which we broadcast (which should never happen). - /// - /// To derive the delayed payment key which is used to sign this input, you must pass the - /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the - /// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided - /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be - /// generated without the secret key using [`chan_utils::derive_public_key`] and only the - /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. - /// - /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is - /// used in the witness script generation), you must pass the counterparty - /// [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to - /// [`ChannelSigner::provide_channel_parameters`]) and the provided - /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to - /// [`chan_utils::derive_public_revocation_key`]. - /// - /// The witness script which is hashed and included in the output `script_pubkey` may be - /// regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived - /// as explained above), our delayed payment pubkey (derived as explained above), and the - /// [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to - /// [`chan_utils::get_revokeable_redeemscript`]. - DelayedPaymentOutput( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor), - /// An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key - /// which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness - /// in the spending input is, thus, simply: - /// ```bitcoin - /// - /// ``` - /// - /// These are generally the result of our counterparty having broadcast the current state, - /// allowing us to claim the non-HTLC-encumbered outputs immediately. - StaticPaymentOutput( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor), -} -use lightning::chain::keysinterface::SpendableOutputDescriptor as SpendableOutputDescriptorImport; -pub(crate) type nativeSpendableOutputDescriptor = SpendableOutputDescriptorImport; - -impl SpendableOutputDescriptor { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeSpendableOutputDescriptor { - match self { - SpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { - let mut outpoint_nonref = Clone::clone(outpoint); - let mut output_nonref = Clone::clone(output); - nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, - output: output_nonref.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeSpendableOutputDescriptor { - match self { - SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { - nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, - output: output.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeSpendableOutputDescriptor) -> Self { - match native { - nativeSpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { - let mut outpoint_nonref = Clone::clone(outpoint); - let mut output_nonref = Clone::clone(output); - SpendableOutputDescriptor::StaticOutput { - outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, - output: crate::c_types::TxOut::from_rust(output_nonref), - } - }, - nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self { - match native { - nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { - SpendableOutputDescriptor::StaticOutput { - outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, - output: crate::c_types::TxOut::from_rust(output), - } - }, - nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, - ) - }, - } - } -} -/// Frees any resources used by the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { } -/// Creates a copy of the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_static_output(outpoint: crate::lightning::chain::transaction::OutPoint, output: crate::c_types::TxOut) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::StaticOutput { - outpoint, - output, - } -} -#[no_mangle] -/// Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_delayed_payment_output(a: crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::DelayedPaymentOutput(a, ) -} -#[no_mangle] -/// Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_static_payment_output(a: crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::StaticPaymentOutput(a, ) -} -/// Checks if two SpendableOutputDescriptors contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_eq(a: &SpendableOutputDescriptor, b: &SpendableOutputDescriptor) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read -pub extern "C" fn SpendableOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write -pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// A trait to handle Lightning channel key material without concretizing the channel type or -/// the signature mechanism. -#[repr(C)] -pub struct ChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the per-commitment point for a specific commitment number - /// - /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - #[must_use] - pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey, - /// Gets the commitment secret for a specific commitment number as part of the revocation process - /// - /// An external signer implementation should error here if the commitment was already signed - /// and should refuse to sign it in the future. - /// - /// May be called more than once for the same index. - /// - /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - #[must_use] - pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, - /// Validate the counterparty's signatures on the holder commitment transaction and HTLCs. - /// - /// This is required in order for the signer to make sure that releasing a commitment - /// secret won't leave us without a broadcastable holder transaction. - /// Policy checks should be implemented in this function, including checking the amount - /// sent to us and checking the HTLCs. - /// - /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - /// A validating signer should ensure that an HTLC output is removed only when the matching - /// preimage is provided, or when the value to holder is restored. - /// - /// Note that all the relevant preimages will be provided, but there may also be additional - /// irrelevant or duplicate preimages. - #[must_use] - pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ, - /// Returns the holder's channel public keys and basepoints. - pub pubkeys: core::cell::UnsafeCell, - /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns - /// Note that this takes a pointer to this object, not the this_ptr like other methods do - /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. - pub set_pubkeys: Option, - /// Returns an arbitrary identifier describing the set of keys which are provided back to you in - /// some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this - /// [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. - #[must_use] - pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Set the counterparty static channel data, including basepoints, - /// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. - /// - /// This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] - /// instance, LDK will call this method exactly once - either immediately after construction - /// (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding - /// information has been generated. - /// - /// channel_parameters.is_populated() MUST be true. - pub provide_channel_parameters: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for ChannelSigner {} -unsafe impl Sync for ChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner { - ChannelSigner { - this_arg: orig.this_arg, - get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point), - release_commitment_secret: Clone::clone(&orig.release_commitment_secret), - validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment), - pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(), - set_pubkeys: Clone::clone(&orig.set_pubkeys), - channel_keys_id: Clone::clone(&orig.channel_keys_id), - provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::ChannelSigner as rustChannelSigner; -impl rustChannelSigner for ChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.release_commitment_secret)(self.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.validate_holder_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.set_pubkeys { - (f)(&self); - } - unsafe { &*self.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.channel_keys_id)(self.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.provide_channel_parameters)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for ChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn ChannelSigner_free(this_ptr: ChannelSigner) { } -impl Drop for ChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait to sign Lightning channel transactions as described in -/// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). -/// -/// Signing services could be implemented on a hardware wallet and should implement signing -/// policies in order to be secure. Please refer to the [VLS Policy -/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) -/// for an example of such policies. -#[repr(C)] -pub struct EcdsaChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - /// - /// Note that if signing fails or is rejected, the channel will be force-closed. - /// - /// Policy checks should be implemented in this function, including checking the amount - /// sent to us and checking the HTLCs. - /// - /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - /// A validating signer should ensure that an HTLC output is removed only when the matching - /// preimage is provided, or when the value to holder is restored. - /// - /// Note that all the relevant preimages will be provided, but there may also be additional - /// irrelevant or duplicate preimages. - #[must_use] - pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Validate the counterparty's revocation. - /// - /// This is required in order for the signer to make sure that the state has moved - /// forward and it is safe to sign the next counterparty commitment. - #[must_use] - pub validate_counterparty_revocation: extern "C" fn (this_arg: *const c_void, idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ, - /// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. - /// - /// This will be called - /// - with a non-revoked `commitment_tx`. - /// - with the latest `commitment_tx` when we initiate a force-close. - /// - with the previous `commitment_tx`, just to get claiming HTLC - /// signatures, if we are reacting to a [`ChannelMonitor`] - /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) - /// that decided to broadcast before it had been updated to the latest `commitment_tx`. - /// - /// This may be called multiple times for the same transaction. - /// - /// An external signer implementation should check that the commitment has not been revoked. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - #[must_use] - pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Create a signature for the given input in a transaction spending an HTLC transaction output - /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state. - /// - /// A justice transaction may claim multiple outputs at the same time if timelocks are - /// similar, but only a signature for the input at index `input` should be signed for here. - /// It may be called multiple times for same output(s) if a fee-bump is needed with regards - /// to an upcoming timelock expiration. - /// - /// Amount is value of the output spent by this input, committed to in the BIP 143 signature. - /// - /// `per_commitment_key` is revocation secret which was provided by our counterparty when they - /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do - /// so). - #[must_use] - pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for the given input in a transaction spending a commitment transaction - /// HTLC output when our counterparty broadcasts an old state. - /// - /// A justice transaction may claim multiple outputs at the same time if timelocks are - /// similar, but only a signature for the input at index `input` should be signed for here. - /// It may be called multiple times for same output(s) if a fee-bump is needed with regards - /// to an upcoming timelock expiration. - /// - /// `amount` is the value of the output spent by this input, committed to in the BIP 143 - /// signature. - /// - /// `per_commitment_key` is revocation secret which was provided by our counterparty when they - /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - /// not allow the spending of any funds by itself (you need our holder revocation_secret to do - /// so). - /// - /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script - /// (which is committed to in the BIP 143 signatures). - #[must_use] - pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - /// transaction, either offered or received. - /// - /// Such a transaction may claim multiples offered outputs at same time if we know the - /// preimage for each when we create it, but only the input at index `input` should be - /// signed for here. It may be called multiple times for same output(s) if a fee-bump is - /// needed with regards to an upcoming timelock expiration. - /// - /// `witness_script` is either an offered or received script as defined in BOLT3 for HTLC - /// outputs. - /// - /// `amount` is value of the output spent by this input, committed to in the BIP 143 signature. - /// - /// `per_commitment_point` is the dynamic point corresponding to the channel state - /// detected onchain. It has been generated by our counterparty and is used to derive - /// channel state keys, which are then included in the witness script and committed to in the - /// BIP 143 signature. - #[must_use] - pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for a (proposed) closing transaction. - /// - /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have - /// chosen to forgo their output as dust. - #[must_use] - pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Computes the signature for a commitment transaction's anchor output used as an - /// input within `anchor_tx`, which spends the commitment transaction, at index `input`. - #[must_use] - pub sign_holder_anchor_input: extern "C" fn (this_arg: *const c_void, anchor_tx: crate::c_types::Transaction, input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Signs a channel announcement message with our funding key proving it comes from one of the - /// channel participants. - /// - /// Channel announcements also require a signature from each node's network key. Our node - /// signature is computed through [`NodeSigner::sign_gossip_message`]. - /// - /// Note that if this fails or is rejected, the channel will not be publicly announced and - /// our counterparty may (though likely will not) close the channel on us for violating the - /// protocol. - #[must_use] - pub sign_channel_announcement_with_funding_key: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Implementation of ChannelSigner for this object. - pub ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EcdsaChannelSigner {} -unsafe impl Sync for EcdsaChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner { - EcdsaChannelSigner { - this_arg: orig.this_arg, - sign_counterparty_commitment: Clone::clone(&orig.sign_counterparty_commitment), - validate_counterparty_revocation: Clone::clone(&orig.validate_counterparty_revocation), - sign_holder_commitment_and_htlcs: Clone::clone(&orig.sign_holder_commitment_and_htlcs), - sign_justice_revoked_output: Clone::clone(&orig.sign_justice_revoked_output), - sign_justice_revoked_htlc: Clone::clone(&orig.sign_justice_revoked_htlc), - sign_counterparty_htlc_transaction: Clone::clone(&orig.sign_counterparty_htlc_transaction), - sign_closing_transaction: Clone::clone(&orig.sign_closing_transaction), - sign_holder_anchor_input: Clone::clone(&orig.sign_holder_anchor_input), - sign_channel_announcement_with_funding_key: Clone::clone(&orig.sign_channel_announcement_with_funding_key), - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner_clone_fields(&orig.ChannelSigner), - free: Clone::clone(&orig.free), - } -} -impl lightning::chain::keysinterface::ChannelSigner for EcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.ChannelSigner.validate_holder_commitment)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.ChannelSigner.set_pubkeys { - (f)(&self.ChannelSigner); - } - unsafe { &*self.ChannelSigner.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.ChannelSigner.channel_keys_id)(self.ChannelSigner.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.ChannelSigner.provide_channel_parameters)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} - -use lightning::chain::keysinterface::EcdsaChannelSigner as rustEcdsaChannelSigner; -impl rustEcdsaChannelSigner for EcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.validate_counterparty_revocation)(self.this_arg, idx, secret.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_closing_transaction)(self.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_holder_anchor_input)(self.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_channel_announcement_with_funding_key)(self.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { } -impl Drop for EcdsaChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A writeable signer. -/// -/// There will always be two instances of a signer per channel, one occupied by the -/// [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. -/// -/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager -/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor -#[repr(C)] -pub struct WriteableEcdsaChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Implementation of EcdsaChannelSigner for this object. - pub EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner, - /// Serialize the object into a byte array - pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for WriteableEcdsaChannelSigner {} -unsafe impl Sync for WriteableEcdsaChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - WriteableEcdsaChannelSigner { - this_arg: orig.this_arg, - EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner), - write: Clone::clone(&orig.write), - free: Clone::clone(&orig.free), - } -} -impl lightning::chain::keysinterface::EcdsaChannelSigner for WriteableEcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.EcdsaChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.this_arg, idx, secret.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment_and_htlcs)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_output)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_htlc)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_closing_transaction)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_anchor_input)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_channel_announcement_with_funding_key)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} -impl lightning::chain::keysinterface::ChannelSigner for WriteableEcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.get_per_commitment_point)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.release_commitment_secret)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_holder_commitment)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys { - (f)(&self.EcdsaChannelSigner.ChannelSigner); - } - unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.EcdsaChannelSigner.ChannelSigner.provide_channel_parameters)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} -impl lightning::util::ser::Writeable for WriteableEcdsaChannelSigner { - fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { - let vec = (self.write)(self.this_arg); - w.write_all(vec.as_slice()) - } -} - -use lightning::chain::keysinterface::WriteableEcdsaChannelSigner as rustWriteableEcdsaChannelSigner; -impl rustWriteableEcdsaChannelSigner for WriteableEcdsaChannelSigner { -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for WriteableEcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { } -impl Drop for WriteableEcdsaChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// Specifies the recipient of an invoice. -/// -/// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign -/// the invoice. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum Recipient { - /// The invoice should be signed with the local node secret key. - Node, - /// The invoice should be signed with the phantom node secret key. This secret key must be the - /// same for all nodes participating in the [phantom node payment]. - /// - /// [phantom node payment]: PhantomKeysManager - PhantomNode, -} -use lightning::chain::keysinterface::Recipient as RecipientImport; -pub(crate) type nativeRecipient = RecipientImport; - -impl Recipient { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeRecipient { - match self { - Recipient::Node => nativeRecipient::Node, - Recipient::PhantomNode => nativeRecipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeRecipient { - match self { - Recipient::Node => nativeRecipient::Node, - Recipient::PhantomNode => nativeRecipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeRecipient) -> Self { - match native { - nativeRecipient::Node => Recipient::Node, - nativeRecipient::PhantomNode => Recipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeRecipient) -> Self { - match native { - nativeRecipient::Node => Recipient::Node, - nativeRecipient::PhantomNode => Recipient::PhantomNode, - } - } -} -/// Creates a copy of the Recipient -#[no_mangle] -pub extern "C" fn Recipient_clone(orig: &Recipient) -> Recipient { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new Node-variant Recipient -pub extern "C" fn Recipient_node() -> Recipient { - Recipient::Node} -#[no_mangle] -/// Utility method to constructs a new PhantomNode-variant Recipient -pub extern "C" fn Recipient_phantom_node() -> Recipient { - Recipient::PhantomNode} -/// A trait that describes a source of entropy. -#[repr(C)] -pub struct EntropySource { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets a unique, cryptographically-secure, random 32-byte value. This method must return a - /// different value each time it is called. - #[must_use] - pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EntropySource {} -unsafe impl Sync for EntropySource {} -#[no_mangle] -pub(crate) extern "C" fn EntropySource_clone_fields(orig: &EntropySource) -> EntropySource { - EntropySource { - this_arg: orig.this_arg, - get_secure_random_bytes: Clone::clone(&orig.get_secure_random_bytes), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::EntropySource as rustEntropySource; -impl rustEntropySource for EntropySource { - fn get_secure_random_bytes(&self) -> [u8; 32] { - let mut ret = (self.get_secure_random_bytes)(self.this_arg); - ret.data - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EntropySource { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EntropySource_free(this_ptr: EntropySource) { } -impl Drop for EntropySource { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait that can handle cryptographic operations at the scope level of a node. -#[repr(C)] -pub struct NodeSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Get secret key material as bytes for use in encrypting and decrypting inbound payment data. - /// - /// If the implementor of this trait supports [phantom node payments], then every node that is - /// intended to be included in the phantom invoice route hints must return the same value from - /// this method. - /// - /// This method must return the same value each time it is called. - /// - /// [phantom node payments]: PhantomKeysManager - #[must_use] - pub get_inbound_payment_key_material: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Get node id based on the provided [`Recipient`]. - /// - /// This method must return the same value each time it is called with a given [`Recipient`] - /// parameter. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub get_node_id: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ, - /// Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if - /// one is provided. Note that this tweak can be applied to `other_key` instead of our node - /// secret, though this is less efficient. - /// - /// Note that if this fails while attempting to forward an HTLC, LDK will panic. The error - /// should be resolved to allow LDK to resume forwarding HTLCs. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub ecdh: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient, other_key: crate::c_types::PublicKey, tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ, - /// Sign an invoice. - /// - /// By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of - /// this trait to parse the invoice and make sure they're signing what they expect, rather than - /// blindly signing the hash. - /// - /// The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. - /// - /// The secret key used to sign the invoice is dependent on the [`Recipient`]. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub sign_invoice: extern "C" fn (this_arg: *const c_void, hrp_bytes: crate::c_types::u8slice, invoice_data: crate::c_types::derived::CVec_U5Z, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, - /// Sign a gossip message. - /// - /// Note that if this fails, LDK may panic and the message will not be broadcast to the network - /// or a possible channel counterparty. If LDK panics, the error should be resolved to allow the - /// message to be broadcast, as otherwise it may prevent one from receiving funds over the - /// corresponding channel. - #[must_use] - pub sign_gossip_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for NodeSigner {} -unsafe impl Sync for NodeSigner {} -#[no_mangle] -pub(crate) extern "C" fn NodeSigner_clone_fields(orig: &NodeSigner) -> NodeSigner { - NodeSigner { - this_arg: orig.this_arg, - get_inbound_payment_key_material: Clone::clone(&orig.get_inbound_payment_key_material), - get_node_id: Clone::clone(&orig.get_node_id), - ecdh: Clone::clone(&orig.ecdh), - sign_invoice: Clone::clone(&orig.sign_invoice), - sign_gossip_message: Clone::clone(&orig.sign_gossip_message), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::NodeSigner as rustNodeSigner; -impl rustNodeSigner for NodeSigner { - fn get_inbound_payment_key_material(&self) -> lightning::chain::keysinterface::KeyMaterial { - let mut ret = (self.get_inbound_payment_key_material)(self.this_arg); - ::lightning::chain::keysinterface::KeyMaterial(ret.data) - } - fn get_node_id(&self, mut recipient: lightning::chain::keysinterface::Recipient) -> Result { - let mut ret = (self.get_node_id)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn ecdh(&self, mut recipient: lightning::chain::keysinterface::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result { - let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) }; - let mut ret = (self.ecdh)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut recipient: lightning::chain::keysinterface::Recipient) -> Result { - let mut local_hrp_bytes = crate::c_types::u8slice::from_slice(hrp_bytes); - let mut local_invoice_data_clone = Vec::new(); local_invoice_data_clone.extend_from_slice(invoice_data); let mut invoice_data = local_invoice_data_clone; let mut local_invoice_data = Vec::new(); for mut item in invoice_data.drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = (self.sign_invoice)(self.this_arg, local_hrp_bytes, local_invoice_data.into(), crate::lightning::chain::keysinterface::Recipient::native_into(recipient)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result { - let mut ret = (self.sign_gossip_message)(self.this_arg, crate::lightning::ln::msgs::UnsignedGossipMessage::native_into(msg)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for NodeSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn NodeSigner_free(this_ptr: NodeSigner) { } -impl Drop for NodeSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait that can return signer instances for individual channels. -#[repr(C)] -pub struct SignerProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through - /// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow - /// implementations of [`SignerProvider`] to maintain a mapping between itself and the generated - /// `channel_keys_id`. - /// - /// This method must return a different value each time it is called. - #[must_use] - pub generate_channel_keys_id: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64, user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes, - /// Derives the private key material backing a `Signer`. - /// - /// To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through - /// [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be - /// re-derived from its `channel_keys_id`, which can be obtained through its trait method - /// [`ChannelSigner::channel_keys_id`]. - #[must_use] - pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner, - /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. - /// This is only called during deserialization of other objects which contain - /// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). - /// The bytes are exactly those which `::write()` writes, and - /// contain no versioning scheme. You may wish to include your own version prefix and ensure - /// you've read all of the provided bytes to ensure no corruption occurred. - /// - /// This method is slowly being phased out -- it will only be called when reading objects - /// written by LDK versions prior to 0.0.113. - /// - /// [`Signer`]: Self::Signer - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - #[must_use] - pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ, - /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Get a script pubkey which we will send funds to when closing a channel. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_shutdown_scriptpubkey: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for SignerProvider {} -unsafe impl Sync for SignerProvider {} -#[no_mangle] -pub(crate) extern "C" fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvider { - SignerProvider { - this_arg: orig.this_arg, - generate_channel_keys_id: Clone::clone(&orig.generate_channel_keys_id), - derive_channel_signer: Clone::clone(&orig.derive_channel_signer), - read_chan_signer: Clone::clone(&orig.read_chan_signer), - get_destination_script: Clone::clone(&orig.get_destination_script), - get_shutdown_scriptpubkey: Clone::clone(&orig.get_shutdown_scriptpubkey), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::SignerProvider as rustSignerProvider; -impl rustSignerProvider for SignerProvider { - type Signer = crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner; - fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] { - let mut ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id.into()); - ret.data - } - fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); - ret - } - fn read_chan_signer(&self, mut reader: &[u8]) -> Result { - let mut local_reader = crate::c_types::u8slice::from_slice(reader); - let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; - local_ret - } - fn get_destination_script(&self) -> bitcoin::blockdata::script::Script { - let mut ret = (self.get_destination_script)(self.this_arg); - ::bitcoin::blockdata::script::Script::from(ret.into_rust()) - } - fn get_shutdown_scriptpubkey(&self) -> lightning::ln::script::ShutdownScript { - let mut ret = (self.get_shutdown_scriptpubkey)(self.this_arg); - *unsafe { Box::from_raw(ret.take_inner()) } - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for SignerProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn SignerProvider_free(this_ptr: SignerProvider) { } -impl Drop for SignerProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} - -use lightning::chain::keysinterface::InMemorySigner as nativeInMemorySignerImport; -pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport; - -/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. -/// -/// This implementation performs no policy checks and is insufficient by itself as -/// a secure external signer. -#[must_use] -#[repr(C)] -pub struct InMemorySigner { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInMemorySigner, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InMemorySigner { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInMemorySigner) }; -} -#[allow(unused)] -impl InMemorySigner { - pub(crate) fn get_native_ref(&self) -> &'static nativeInMemorySigner { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInMemorySigner { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the -/// holder's anchor output in a commitment transaction, if one is present. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_key; - inner_val.as_ref() -} -/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the -/// holder's anchor output in a commitment transaction, if one is present. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_key = val.into_rust(); -} -/// Holder secret key for blinded revocation pubkey. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_base_key; - inner_val.as_ref() -} -/// Holder secret key for blinded revocation pubkey. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_base_key = val.into_rust(); -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_key; - inner_val.as_ref() -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_key = val.into_rust(); -} -/// Holder secret key used in an HTLC transaction. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_base_key; - inner_val.as_ref() -} -/// Holder secret key used in an HTLC transaction. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_base_key = val.into_rust(); -} -/// Holder HTLC secret key used in commitment transaction HTLC outputs. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_base_key; - inner_val.as_ref() -} -/// Holder HTLC secret key used in commitment transaction HTLC outputs. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_base_key = val.into_rust(); -} -/// Commitment seed. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_seed; - inner_val -} -/// Commitment seed. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_seed = val.data; -} -impl Clone for InMemorySigner { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InMemorySigner -pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { - orig.clone() -} -/// Creates a new [`InMemorySigner`]. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes, mut rand_bytes_unique_start: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data, rand_bytes_unique_start.data); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns the counterparty's pubkeys. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_pubkeys(); - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } -} - -/// Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable -/// transactions, i.e., the amount of time that we have to wait to recover our funds if we -/// broadcast a transaction. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> u16 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_selected_contest_delay(); - ret -} - -/// Returns the `contest_delay` value specified by us and applied on transactions broadcastable -/// by our counterparty, i.e., the amount of time that they have to wait to recover their funds -/// if they broadcast a transaction. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> u16 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.holder_selected_contest_delay(); - ret -} - -/// Returns whether the holder is the initiator. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_is_outbound(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_outbound(); - ret -} - -/// Funding outpoint -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::chain::transaction::OutPoint { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint(); - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} - -/// Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or -/// building transactions. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_channel_parameters(); - crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false } -} - -/// Returns whether anchors should be used. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_opt_anchors(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret -} - -/// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described -/// by `descriptor`, returning the witness stack for the input. -/// -/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, -/// is not spending the outpoint described by [`descriptor.outpoint`], -/// or if an output descriptor `script_pubkey` does not match the one we can spend. -/// -/// [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sign the single input of `spend_tx` at index `input_idx` which spends the output -/// described by `descriptor`, returning the witness stack for the input. -/// -/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, -/// is not spending the outpoint described by [`descriptor.outpoint`], does not have a -/// sequence set to [`descriptor.to_self_delay`], or if an output descriptor -/// `script_pubkey` does not match the one we can spend. -/// -/// [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint -/// [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: InMemorySigner_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::ChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_ChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new ChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::ChannelSigner { - crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - } -} - -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { - let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1); - crate::c_types::PublicKey::from_rust(&ret) -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_preimages); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { - let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } -} -extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) { - // This is a bit race-y in the general case, but for our specific use-cases today, we're safe - // Specifically, we must ensure that the first time we're called it can never be in parallel - if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() { - *unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); - } -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} -extern "C" fn InMemorySigner_ChannelSigner_provide_channel_parameters(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { - >::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref()) -} - -impl From for crate::lightning::chain::keysinterface::EcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_EcdsaChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::EcdsaChannelSigner { - crate::lightning::chain::keysinterface::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, - sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, - sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, - sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, - sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, - sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, - sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - }, - } -} - -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_preimages, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = >::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input(this_arg: *const c_void, mut anchor_tx: crate::c_types::Transaction, mut input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, - sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, - sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, - sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, - sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, - sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, - sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - }, - }, - write: InMemorySigner_write_void, - } -} - - -#[no_mangle] -/// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read -pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) -} -#[no_mangle] -/// Read a InMemorySigner from a byte array, created by InMemorySigner_write -pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { - let arg_conv = arg; - let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} - -use lightning::chain::keysinterface::KeysManager as nativeKeysManagerImport; -pub(crate) type nativeKeysManager = nativeKeysManagerImport; - -/// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a -/// 32-byte seed for use as a BIP 32 extended key and derives keys from that. -/// -/// Your `node_id` is seed/0'. -/// Unilateral closes may use seed/1'. -/// Cooperative closes may use seed/2'. -/// The two close keys may be needed to claim on-chain funds! -/// -/// This struct cannot be used for nodes that wish to support receiving phantom payments; -/// [`PhantomKeysManager`] must be used instead. -/// -/// Note that switching between this struct and [`PhantomKeysManager`] will invalidate any -/// previously issued invoices and attempts to pay previous invoices will fail. -#[must_use] -#[repr(C)] -pub struct KeysManager { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeKeysManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for KeysManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn KeysManager_free(this_obj: KeysManager) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeKeysManager) }; -} -#[allow(unused)] -impl KeysManager { - pub(crate) fn get_native_ref(&self) -> &'static nativeKeysManager { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeKeysManager { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., -/// your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). -/// `starting_time` isn't strictly required to actually be a time, but it must absolutely, -/// without a doubt, be unique to this instance. ie if you start multiple times with the same -/// `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this -/// is to simply use the current time (with very high precision). -/// -/// The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, -/// obviously, `starting_time` should be unique every time you reload the library - it is only -/// used to generate new ephemeral key data (which will be stored by the individual channel if -/// necessary). -/// -/// Note that the seed is required to recover certain on-chain funds independent of -/// [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required -/// for any channel, and some on-chain during-closing funds. -/// -/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> crate::lightning::chain::keysinterface::KeysManager { - let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos); - crate::lightning::chain::keysinterface::KeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::KeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - -/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::chain::keysinterface::KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an -/// output to the given change destination (if sufficient change value remains). The -/// transaction will have a feerate, at least, of the given value. -/// -/// Returns `Err(())` if the output value is greater than the input value minus required fee, -/// if a descriptor was duplicated, or if an output descriptor `script_pubkey` -/// does not match the one we can spend. -/// -/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. -/// -/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used -/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &crate::lightning::chain::keysinterface::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_EntropySource(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: KeysManager_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn KeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::NodeSigner { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_NodeSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new NodeSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_NodeSigner(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::NodeSigner { - crate::lightning::chain::keysinterface::NodeSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_inbound_payment_key_material: KeysManager_NodeSigner_get_inbound_payment_key_material, - get_node_id: KeysManager_NodeSigner_get_node_id, - ecdh: KeysManager_NodeSigner_ecdh, - sign_invoice: KeysManager_NodeSigner_sign_invoice, - sign_gossip_message: KeysManager_NodeSigner_sign_gossip_message, - } -} - -#[must_use] -extern "C" fn KeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret.0 } -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::SignerProvider { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_SignerProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new SignerProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_SignerProvider(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::SignerProvider { - crate::lightning::chain::keysinterface::SignerProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - generate_channel_keys_id: KeysManager_SignerProvider_generate_channel_keys_id, - derive_channel_signer: KeysManager_SignerProvider_derive_channel_signer, - read_chan_signer: KeysManager_SignerProvider_read_chan_signer, - get_destination_script: KeysManager_SignerProvider_get_destination_script, - get_shutdown_scriptpubkey: KeysManager_SignerProvider_get_shutdown_scriptpubkey, - } -} - -#[must_use] -extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data); - Into::into(ret) -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - ret.into_bytes().into() -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - - -use lightning::chain::keysinterface::PhantomKeysManager as nativePhantomKeysManagerImport; -pub(crate) type nativePhantomKeysManager = nativePhantomKeysManagerImport; - -/// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node -/// payments. -/// -/// A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be -/// paid to one of multiple nodes. This works because we encode the invoice route hints such that -/// LDK will recognize an incoming payment as destined for a phantom node, and collect the payment -/// itself without ever needing to forward to this fake node. -/// -/// Phantom node payments are useful for load balancing between multiple LDK nodes. They also -/// provide some fault tolerance, because payers will automatically retry paying other provided -/// nodes in the case that one node goes down. -/// -/// Note that multi-path payments are not supported in phantom invoices for security reasons. -/// Switching between this struct and [`KeysManager`] will invalidate any previously issued -/// invoices and attempts to pay previous invoices will fail. -#[must_use] -#[repr(C)] -pub struct PhantomKeysManager { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativePhantomKeysManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for PhantomKeysManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PhantomKeysManager_free(this_obj: PhantomKeysManager) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn PhantomKeysManager_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomKeysManager) }; -} -#[allow(unused)] -impl PhantomKeysManager { - pub(crate) fn get_native_ref(&self) -> &'static nativePhantomKeysManager { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomKeysManager { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativePhantomKeysManager { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_EntropySource(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: PhantomKeysManager_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::NodeSigner { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_NodeSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new NodeSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_NodeSigner(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::NodeSigner { - crate::lightning::chain::keysinterface::NodeSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_inbound_payment_key_material: PhantomKeysManager_NodeSigner_get_inbound_payment_key_material, - get_node_id: PhantomKeysManager_NodeSigner_get_node_id, - ecdh: PhantomKeysManager_NodeSigner_ecdh, - sign_invoice: PhantomKeysManager_NodeSigner_sign_invoice, - sign_gossip_message: PhantomKeysManager_NodeSigner_sign_gossip_message, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret.0 } -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::SignerProvider { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_SignerProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new SignerProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_SignerProvider(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::SignerProvider { - crate::lightning::chain::keysinterface::SignerProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - generate_channel_keys_id: PhantomKeysManager_SignerProvider_generate_channel_keys_id, - derive_channel_signer: PhantomKeysManager_SignerProvider_derive_channel_signer, - read_chan_signer: PhantomKeysManager_SignerProvider_read_chan_signer, - get_destination_script: PhantomKeysManager_SignerProvider_get_destination_script, - get_shutdown_scriptpubkey: PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data); - Into::into(ret) -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - ret.into_bytes().into() -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` -/// that is shared across all nodes that intend to participate in [phantom node payments] -/// together. -/// -/// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and -/// `starting_time_nanos`. -/// -/// `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the -/// same across restarts, or else inbound payments may fail. -/// -/// [phantom node payments]: PhantomKeysManager -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32, cross_node_seed: *const [u8; 32]) -> crate::lightning::chain::keysinterface::PhantomKeysManager { - let mut ret = lightning::chain::keysinterface::PhantomKeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos, unsafe { &*cross_node_seed}); - crate::lightning::chain::keysinterface::PhantomKeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// See [`KeysManager::spend_spendable_outputs`] for documentation on this method. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_spend_spendable_outputs(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// See [`KeysManager::derive_channel_keys`] for documentation on this method. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_derive_channel_keys(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_get_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - -/// Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the -/// last-hop onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_get_phantom_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index 74fe721..54dd4ef 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -20,7 +20,6 @@ pub mod chaininterface; pub mod chainmonitor; pub mod channelmonitor; pub mod transaction; -pub mod keysinterface; mod onchaintx { use alloc::str::FromStr; @@ -321,8 +320,7 @@ pub struct Confirm { /// /// [`transactions_confirmed`]: Self::transactions_confirmed /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed - #[must_use] - pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ, + pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -357,7 +355,7 @@ impl rustConfirm for Confirm { } fn get_relevant_txids(&self) -> Vec<(bitcoin::hash_types::Txid, Option)> { let mut ret = (self.get_relevant_txids)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&orig_ret_0_1.data[..]).unwrap() }) }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), local_orig_ret_0_1); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = { /*orig_ret_0_1*/ let orig_ret_0_1_opt = orig_ret_0_1; if orig_ret_0_1_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ orig_ret_0_1_opt.take() }.data[..]).unwrap() }})} }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), local_orig_ret_0_1); local_ret_0 }); }; local_ret } } @@ -555,7 +553,6 @@ pub struct Watch { /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected - #[must_use] pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. /// @@ -563,7 +560,6 @@ pub struct Watch { /// [`ChannelMonitorUpdateStatus`] for invariants around returning an error. /// /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor - #[must_use] pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, update: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Returns any monitor events since the last call. Subsequent calls must only return new /// events. @@ -574,7 +570,6 @@ pub struct Watch { /// /// For details on asynchronous [`ChannelMonitor`] updating and returning /// [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. - #[must_use] pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -594,8 +589,8 @@ pub(crate) extern "C" fn Watch_clone_fields(orig: &Watch) -> Watch { } use lightning::chain::Watch as rustWatch; -impl rustWatch for Watch { - fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { +impl rustWatch for Watch { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { let mut ret = (self.watch_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(monitor), is_owned: true }); ret.into_native() } @@ -769,20 +764,16 @@ impl WatchedOutput { } } /// First block where the transaction output may have been spent. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::derived::COption_BlockHashZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().block_hash; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).into_inner() } } }; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) }; local_inner_val } /// First block where the transaction output may have been spent. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) { - let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) }; +pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::COption_BlockHashZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.block_hash = local_val; } /// Outpoint identifying the transaction output. @@ -810,8 +801,8 @@ pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, /// Constructs a new WatchedOutput given each field #[must_use] #[no_mangle] -pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { - let mut local_block_hash_arg = if block_hash_arg.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap() }) }; +pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::derived::COption_BlockHashZ, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { + let mut local_block_hash_arg = { /*block_hash_arg*/ let block_hash_arg_opt = block_hash_arg; if block_hash_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ block_hash_arg_opt.take() }.data[..]).unwrap() }})} }; WatchedOutput { inner: ObjOps::heap_alloc(nativeWatchedOutput { block_hash: local_block_hash_arg, outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, diff --git a/lightning-c-bindings/src/lightning/events.rs b/lightning-c-bindings/src/lightning/events.rs deleted file mode 100644 index 50b6875..0000000 --- a/lightning-c-bindings/src/lightning/events.rs +++ /dev/null @@ -1,3634 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Events are returned from various bits in the library which indicate some action must be taken -//! by the client. -//! -//! Because we don't have a built-in runtime, it's up to the client to call events at a time in the -//! future, as well as generate and broadcast funding transactions handle payment preimages and a -//! few other things. - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -/// Some information provided on receipt of payment depends on whether the payment received is a -/// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PaymentPurpose { - /// Information for receiving a payment that we generated an invoice for. - InvoicePayment { - /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via - /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - /// [`ChannelManager::claim_funds`]. - /// - /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_preimage: crate::c_types::ThirtyTwoBytes, - /// The \"payment secret\". This authenticates the sender to the recipient, preventing a - /// number of deanonymization attacks during the routing process. - /// It is provided here for your reference, however its accuracy is enforced directly by - /// [`ChannelManager`] using the values you previously provided to - /// [`ChannelManager::create_inbound_payment`] or - /// [`ChannelManager::create_inbound_payment_for_hash`]. - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - payment_secret: crate::c_types::ThirtyTwoBytes, - }, - /// Because this is a spontaneous payment, the payer generated their own preimage rather than us - /// (the payee) providing a preimage. - SpontaneousPayment( - crate::c_types::ThirtyTwoBytes), -} -use lightning::events::PaymentPurpose as PaymentPurposeImport; -pub(crate) type nativePaymentPurpose = PaymentPurposeImport; - -impl PaymentPurpose { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePaymentPurpose { - match self { - PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data) }) }; - let mut payment_secret_nonref = Clone::clone(payment_secret); - nativePaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage_nonref, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data), - } - }, - PaymentPurpose::SpontaneousPayment (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a_nonref.data), - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePaymentPurpose { - match self { - PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; - nativePaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data), - } - }, - PaymentPurpose::SpontaneousPayment (mut a, ) => { - nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a.data), - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self { - match native { - nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } }; - let mut payment_secret_nonref = Clone::clone(payment_secret); - PaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage_nonref, - payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, - } - }, - nativePaymentPurpose::SpontaneousPayment (ref a, ) => { - let mut a_nonref = Clone::clone(a); - PaymentPurpose::SpontaneousPayment ( - crate::c_types::ThirtyTwoBytes { data: a_nonref.0 }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePaymentPurpose) -> Self { - match native { - nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { - let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } }; - PaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage, - payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, - } - }, - nativePaymentPurpose::SpontaneousPayment (mut a, ) => { - PaymentPurpose::SpontaneousPayment ( - crate::c_types::ThirtyTwoBytes { data: a.0 }, - ) - }, - } - } -} -/// Frees any resources used by the PaymentPurpose -#[no_mangle] -pub extern "C" fn PaymentPurpose_free(this_ptr: PaymentPurpose) { } -/// Creates a copy of the PaymentPurpose -#[no_mangle] -pub extern "C" fn PaymentPurpose_clone(orig: &PaymentPurpose) -> PaymentPurpose { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new InvoicePayment-variant PaymentPurpose -pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { - PaymentPurpose::InvoicePayment { - payment_preimage, - payment_secret, - } -} -#[no_mangle] -/// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose -pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { - PaymentPurpose::SpontaneousPayment(a, ) -} -/// Checks if two PaymentPurposes contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read -pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write -pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may -/// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. -/// -/// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate -/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PathFailure { - /// We failed to initially send the payment and no HTLC was committed to. Contains the relevant - /// error. - InitialSend { - /// The error surfaced from initial send. - err: crate::lightning::util::errors::APIError, - }, - /// A hop on the path failed to forward our payment. - OnPath { - /// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing - /// decisions can take into account the update. - /// - /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - network_update: crate::c_types::derived::COption_NetworkUpdateZ, - }, -} -use lightning::events::PathFailure as PathFailureImport; -pub(crate) type nativePathFailure = PathFailureImport; - -impl PathFailure { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePathFailure { - match self { - PathFailure::InitialSend {ref err, } => { - let mut err_nonref = Clone::clone(err); - nativePathFailure::InitialSend { - err: err_nonref.into_native(), - } - }, - PathFailure::OnPath {ref network_update, } => { - let mut network_update_nonref = Clone::clone(network_update); - let mut local_network_update_nonref = { /*network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; if network_update_nonref_opt.is_none() { None } else { Some({ { { network_update_nonref_opt.take() }.into_native() }})} }; - nativePathFailure::OnPath { - network_update: local_network_update_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePathFailure { - match self { - PathFailure::InitialSend {mut err, } => { - nativePathFailure::InitialSend { - err: err.into_native(), - } - }, - PathFailure::OnPath {mut network_update, } => { - let mut local_network_update = { /*network_update*/ let network_update_opt = network_update; if network_update_opt.is_none() { None } else { Some({ { { network_update_opt.take() }.into_native() }})} }; - nativePathFailure::OnPath { - network_update: local_network_update, - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePathFailure) -> Self { - match native { - nativePathFailure::InitialSend {ref err, } => { - let mut err_nonref = Clone::clone(err); - PathFailure::InitialSend { - err: crate::lightning::util::errors::APIError::native_into(err_nonref), - } - }, - nativePathFailure::OnPath {ref network_update, } => { - let mut network_update_nonref = Clone::clone(network_update); - let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) }; - PathFailure::OnPath { - network_update: local_network_update_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePathFailure) -> Self { - match native { - nativePathFailure::InitialSend {mut err, } => { - PathFailure::InitialSend { - err: crate::lightning::util::errors::APIError::native_into(err), - } - }, - nativePathFailure::OnPath {mut network_update, } => { - let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update.unwrap()) }) }; - PathFailure::OnPath { - network_update: local_network_update, - } - }, - } - } -} -/// Frees any resources used by the PathFailure -#[no_mangle] -pub extern "C" fn PathFailure_free(this_ptr: PathFailure) { } -/// Creates a copy of the PathFailure -#[no_mangle] -pub extern "C" fn PathFailure_clone(orig: &PathFailure) -> PathFailure { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new InitialSend-variant PathFailure -pub extern "C" fn PathFailure_initial_send(err: crate::lightning::util::errors::APIError) -> PathFailure { - PathFailure::InitialSend { - err, - } -} -#[no_mangle] -/// Utility method to constructs a new OnPath-variant PathFailure -pub extern "C" fn PathFailure_on_path(network_update: crate::c_types::derived::COption_NetworkUpdateZ) -> PathFailure { - PathFailure::OnPath { - network_update, - } -} -/// Checks if two PathFailures contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PathFailure object into a byte array which can be read by PathFailure_read -pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PathFailure from a byte array, created by PathFailure_write -pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// The reason the channel was closed. See individual variants more details. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum ClosureReason { - /// Closure generated from receiving a peer error message. - /// - /// Our counterparty may have broadcasted their latest commitment state, and we have - /// as well. - CounterpartyForceClosed { - /// The error which the peer sent us. - /// - /// Be careful about printing the peer_msg, a well-crafted message could exploit - /// a security vulnerability in the terminal emulator or the logging subsystem. - /// To be safe, use `Display` on `UntrustedString` - /// - /// [`UntrustedString`]: crate::util::string::UntrustedString - peer_msg: crate::lightning::util::string::UntrustedString, - }, - /// Closure generated from [`ChannelManager::force_close_channel`], called by the user. - /// - /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - HolderForceClosed, - /// The channel was closed after negotiating a cooperative close and we've now broadcasted - /// the cooperative close transaction. Note the shutdown may have been initiated by us. - CooperativeClosure, - /// A commitment transaction was confirmed on chain, closing the channel. Most likely this - /// commitment transaction came from our counterparty, but it may also have come from - /// a copy of our own `ChannelMonitor`. - CommitmentTxConfirmed, - /// The funding transaction failed to confirm in a timely manner on an inbound channel. - FundingTimedOut, - /// Closure generated from processing an event, likely a HTLC forward/relay/reception. - ProcessingError { - /// A developer-readable error message which we generated. - err: crate::c_types::Str, - }, - /// The peer disconnected prior to funding completing. In this case the spec mandates that we - /// forget the channel entirely - we can attempt again if the peer reconnects. - /// - /// This includes cases where we restarted prior to funding completion, including prior to the - /// initial [`ChannelMonitor`] persistence completing. - /// - /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the - /// peer because of mutual incompatibility between us and our channel counterparty. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - DisconnectedPeer, - /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than - /// the [`ChannelManager`] deserialized. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - OutdatedChannelManager, -} -use lightning::events::ClosureReason as ClosureReasonImport; -pub(crate) type nativeClosureReason = ClosureReasonImport; - -impl ClosureReason { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeClosureReason { - match self { - ClosureReason::CounterpartyForceClosed {ref peer_msg, } => { - let mut peer_msg_nonref = Clone::clone(peer_msg); - nativeClosureReason::CounterpartyForceClosed { - peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, - } - }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, - ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, - ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, - ClosureReason::ProcessingError {ref err, } => { - let mut err_nonref = Clone::clone(err); - nativeClosureReason::ProcessingError { - err: err_nonref.into_string(), - } - }, - ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, - ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeClosureReason { - match self { - ClosureReason::CounterpartyForceClosed {mut peer_msg, } => { - nativeClosureReason::CounterpartyForceClosed { - peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, - } - }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, - ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, - ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, - ClosureReason::ProcessingError {mut err, } => { - nativeClosureReason::ProcessingError { - err: err.into_string(), - } - }, - ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, - ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeClosureReason) -> Self { - match native { - nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => { - let mut peer_msg_nonref = Clone::clone(peer_msg); - ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, - } - }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, - nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, - nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, - nativeClosureReason::ProcessingError {ref err, } => { - let mut err_nonref = Clone::clone(err); - ClosureReason::ProcessingError { - err: err_nonref.into(), - } - }, - nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, - nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeClosureReason) -> Self { - match native { - nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => { - ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, - } - }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, - nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, - nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, - nativeClosureReason::ProcessingError {mut err, } => { - ClosureReason::ProcessingError { - err: err.into(), - } - }, - nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, - nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, - } - } -} -/// Frees any resources used by the ClosureReason -#[no_mangle] -pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { } -/// Creates a copy of the ClosureReason -#[no_mangle] -pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason { - ClosureReason::CounterpartyForceClosed { - peer_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new HolderForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason { - ClosureReason::HolderForceClosed} -#[no_mangle] -/// Utility method to constructs a new CooperativeClosure-variant ClosureReason -pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason { - ClosureReason::CooperativeClosure} -#[no_mangle] -/// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason -pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason { - ClosureReason::CommitmentTxConfirmed} -#[no_mangle] -/// Utility method to constructs a new FundingTimedOut-variant ClosureReason -pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason { - ClosureReason::FundingTimedOut} -#[no_mangle] -/// Utility method to constructs a new ProcessingError-variant ClosureReason -pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason { - ClosureReason::ProcessingError { - err, - } -} -#[no_mangle] -/// Utility method to constructs a new DisconnectedPeer-variant ClosureReason -pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason { - ClosureReason::DisconnectedPeer} -#[no_mangle] -/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason -pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason { - ClosureReason::OutdatedChannelManager} -/// Checks if two ClosureReasons contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read -pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a ClosureReason from a byte array, created by ClosureReason_write -pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum HTLCDestination { - /// We tried forwarding to a channel but failed to do so. An example of such an instance is when - /// there is insufficient capacity in our outbound channel. - NextHopChannel { - /// The `node_id` of the next node. For backwards compatibility, this field is - /// marked as optional, versions prior to 0.0.110 may not always be able to provide - /// counterparty node information. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - node_id: crate::c_types::PublicKey, - /// The outgoing `channel_id` between us and the next node. - channel_id: crate::c_types::ThirtyTwoBytes, - }, - /// Scenario where we are unsure of the next node to forward the HTLC to. - UnknownNextHop { - /// Short channel id we are requesting to forward an HTLC to. - requested_forward_scid: u64, - }, - /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate - /// intercept HTLC. - InvalidForward { - /// Short channel id we are requesting to forward an HTLC to. - requested_forward_scid: u64, - }, - /// Failure scenario where an HTLC may have been forwarded to be intended for us, - /// but is invalid for some reason, so we reject it. - /// - /// Some of the reasons may include: - /// * HTLC Timeouts - /// * Excess HTLCs for a payment that we have already fully received, over-paying for the - /// payment, - /// * The counterparty node modified the HTLC in transit, - /// * A probing attack where an intermediary node is trying to detect if we are the ultimate - /// recipient for a payment. - FailedPayment { - /// The payment hash of the payment we attempted to process. - payment_hash: crate::c_types::ThirtyTwoBytes, - }, -} -use lightning::events::HTLCDestination as HTLCDestinationImport; -pub(crate) type nativeHTLCDestination = HTLCDestinationImport; - -impl HTLCDestination { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeHTLCDestination { - match self { - HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) }; - let mut channel_id_nonref = Clone::clone(channel_id); - nativeHTLCDestination::NextHopChannel { - node_id: local_node_id_nonref, - channel_id: channel_id_nonref.data, - } - }, - HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - nativeHTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - HTLCDestination::InvalidForward {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - nativeHTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - HTLCDestination::FailedPayment {ref payment_hash, } => { - let mut payment_hash_nonref = Clone::clone(payment_hash); - nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeHTLCDestination { - match self { - HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { - let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) }; - nativeHTLCDestination::NextHopChannel { - node_id: local_node_id, - channel_id: channel_id.data, - } - }, - HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { - nativeHTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid, - } - }, - HTLCDestination::InvalidForward {mut requested_forward_scid, } => { - nativeHTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid, - } - }, - HTLCDestination::FailedPayment {mut payment_hash, } => { - nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self { - match native { - nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut local_node_id_nonref = if node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id_nonref.unwrap())) } }; - let mut channel_id_nonref = Clone::clone(channel_id); - HTLCDestination::NextHopChannel { - node_id: local_node_id_nonref, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - } - }, - nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - HTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - nativeHTLCDestination::InvalidForward {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - HTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - nativeHTLCDestination::FailedPayment {ref payment_hash, } => { - let mut payment_hash_nonref = Clone::clone(payment_hash); - HTLCDestination::FailedPayment { - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeHTLCDestination) -> Self { - match native { - nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { - let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } }; - HTLCDestination::NextHopChannel { - node_id: local_node_id, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - } - }, - nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { - HTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid, - } - }, - nativeHTLCDestination::InvalidForward {mut requested_forward_scid, } => { - HTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid, - } - }, - nativeHTLCDestination::FailedPayment {mut payment_hash, } => { - HTLCDestination::FailedPayment { - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - } - }, - } - } -} -/// Frees any resources used by the HTLCDestination -#[no_mangle] -pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { } -/// Creates a copy of the HTLCDestination -#[no_mangle] -pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new NextHopChannel-variant HTLCDestination -pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { - HTLCDestination::NextHopChannel { - node_id, - channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new UnknownNextHop-variant HTLCDestination -pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination { - HTLCDestination::UnknownNextHop { - requested_forward_scid, - } -} -#[no_mangle] -/// Utility method to constructs a new InvalidForward-variant HTLCDestination -pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) -> HTLCDestination { - HTLCDestination::InvalidForward { - requested_forward_scid, - } -} -#[no_mangle] -/// Utility method to constructs a new FailedPayment-variant HTLCDestination -pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { - HTLCDestination::FailedPayment { - payment_hash, - } -} -/// Checks if two HTLCDestinations contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read -pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a HTLCDestination from a byte array, created by HTLCDestination_write -pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// The reason the payment failed. Used in [`Event::PaymentFailed`]. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PaymentFailureReason { - /// The intended recipient rejected our payment. - RecipientRejected, - /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. - /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - UserAbandoned, - /// We exhausted all of our retry attempts while trying to send the payment, or we - /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry - /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will - /// have come before this. - /// - /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout - RetriesExhausted, - /// The payment expired while retrying, based on the provided - /// [`PaymentParameters::expiry_time`]. - /// - /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time - PaymentExpired, - /// We failed to find a route while retrying the payment. - RouteNotFound, - /// This error should generally never happen. This likely means that there is a problem with - /// your router. - UnexpectedError, -} -use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; -pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; - -impl PaymentFailureReason { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePaymentFailureReason { - match self { - PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, - PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, - PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, - PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, - PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, - PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePaymentFailureReason { - match self { - PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, - PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, - PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, - PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, - PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, - PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self { - match native { - nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, - nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, - nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, - nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, - nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, - nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self { - match native { - nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, - nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, - nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, - nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, - nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, - nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, - } - } -} -/// Creates a copy of the PaymentFailureReason -#[no_mangle] -pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason { - PaymentFailureReason::RecipientRejected} -#[no_mangle] -/// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason { - PaymentFailureReason::UserAbandoned} -#[no_mangle] -/// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason { - PaymentFailureReason::RetriesExhausted} -#[no_mangle] -/// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason { - PaymentFailureReason::PaymentExpired} -#[no_mangle] -/// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason { - PaymentFailureReason::RouteNotFound} -#[no_mangle] -/// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { - PaymentFailureReason::UnexpectedError} -/// Checks if two PaymentFailureReasons contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read -pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write -pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// An Event which you should probably take some action in response to. -/// -/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use -/// them directly as they don't round-trip exactly (for example FundingGenerationReady is never -/// written as it makes no sense to respond to it after reconnecting to peers). -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum Event { - /// Used to indicate that the client should generate a funding transaction with the given - /// parameters and then call [`ChannelManager::funding_transaction_generated`]. - /// Generated in [`ChannelManager`] message handling. - /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your - /// counterparty can steal your funds! - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - FundingGenerationReady { - /// The random channel_id we picked which you'll need to pass into - /// [`ChannelManager::funding_transaction_generated`]. - /// - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The counterparty's node_id, which you'll need to pass back into - /// [`ChannelManager::funding_transaction_generated`]. - /// - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - counterparty_node_id: crate::c_types::PublicKey, - /// The value, in satoshis, that the output should have. - channel_value_satoshis: u64, - /// The script which should be used in the transaction output. - output_script: crate::c_types::derived::CVec_u8Z, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a - /// random value for an inbound channel. This may be zero for objects serialized with LDK - /// versions prior to 0.0.113. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - user_channel_id: crate::c_types::U128, - }, - /// Indicates that we've been offered a payment and it needs to be claimed via calling - /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. - /// - /// Note that if the preimage is not known, you should call - /// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] - /// to free up resources for this HTLC and avoid network congestion. - /// If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], - /// or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be - /// automatically failed. - /// - /// # Note - /// LDK will not stop an inbound payment from being paid multiple times, so multiple - /// `PaymentClaimable` events may be generated for the same payment. In such a case it is - /// polite (and required in the lightning specification) to fail the payment the second time - /// and give the sender their money back rather than accepting double payment. - /// - /// # Note - /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards - /// [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason - PaymentClaimable { - /// The node that will receive the payment after it has been claimed. - /// This is useful to identify payments received via [phantom nodes]. - /// This field will always be filled in when the event was generated by LDK versions - /// 0.0.113 and above. - /// - /// [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - receiver_node_id: crate::c_types::PublicKey, - /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will - /// not stop you from registering duplicate payment hashes for inbound payments. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The fields in the onion which were received with each HTLC. Only fields which were - /// identical in each HTLC involved in the payment will be included here. - /// - /// Payments received on LDK versions prior to 0.0.115 will have this field unset. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, - /// The value, in thousandths of a satoshi, that this payment is for. - amount_msat: u64, - /// Information for claiming this received payment, based on whether the purpose of the - /// payment is to pay an invoice or to send a spontaneous payment. - purpose: crate::lightning::events::PaymentPurpose, - /// The `channel_id` indicating over which channel we received the payment. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - via_channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` indicating over which channel we received the payment. - via_user_channel_id: crate::c_types::derived::COption_u128Z, - /// The block height at which this payment will be failed back and will no longer be - /// eligible for claiming. - /// - /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to - /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - claim_deadline: crate::c_types::derived::COption_u32Z, - }, - /// Indicates a payment has been claimed and we've received money! - /// - /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response - /// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a - /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding - /// [`Event::PaymentClaimable`] event. - /// - /// # Note - /// LDK will not stop an inbound payment from being paid multiple times, so multiple - /// `PaymentClaimable` events may be generated for the same payment. If you then call - /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get - /// multiple `PaymentClaimed` events. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - PaymentClaimed { - /// The node that received the payment. - /// This is useful to identify payments which were received via [phantom nodes]. - /// This field will always be filled in when the event was generated by LDK versions - /// 0.0.113 and above. - /// - /// [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - receiver_node_id: crate::c_types::PublicKey, - /// The payment hash of the claimed payment. Note that LDK will not stop you from - /// registering duplicate payment hashes for inbound payments. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The value, in thousandths of a satoshi, that this payment is for. - amount_msat: u64, - /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a - /// spontaneous payment. - purpose: crate::lightning::events::PaymentPurpose, - }, - /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target - /// and we got back the payment preimage for it). - /// - /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` - /// event. In this situation, you SHOULD treat this payment as having succeeded. - PaymentSent { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_id: crate::c_types::ThirtyTwoBytes, - /// 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 - /// store it somehow! - payment_preimage: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// 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 - fee_paid_msat: crate::c_types::derived::COption_u64Z, - }, - /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events - /// provide failure information for each path attempt in the payment, including retries. - /// - /// This event is provided once there are no further pending HTLCs for the payment and the - /// payment is no longer retryable, due either to the [`Retry`] provided or - /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment. - /// - /// [`Retry`]: crate::ln::channelmanager::Retry - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - PaymentFailed { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The reason the payment failed. This is only `None` for events generated or serialized - /// by versions prior to 0.0.115. - reason: crate::c_types::derived::COption_PaymentFailureReasonZ, - }, - /// Indicates that a path for an outbound payment was successful. - /// - /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See - /// [`Event::PaymentSent`] for obtaining the payment preimage. - PaymentPathSuccessful { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that was successful. - /// - /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain. - path: crate::lightning::routing::router::Path, - }, - /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to - /// handle the HTLC. - /// - /// Note that this does *not* indicate that all paths for an MPP payment have failed, see - /// [`Event::PaymentFailed`]. - /// - /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have - /// been exhausted. - /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - PaymentPathFailed { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// Indicates the payment was rejected for some reason by the recipient. This implies that - /// the payment has failed, not just the route in question. If this is not set, the payment may - /// be retried via a different route. - payment_failed_permanently: bool, - /// Extra error details based on the failure type. May contain an update that needs to be - /// applied to the [`NetworkGraph`]. - /// - /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - failure: crate::lightning::events::PathFailure, - /// The payment path that failed. - path: crate::lightning::routing::router::Path, - /// The channel responsible for the failed payment path. - /// - /// Note that for route hints or for the first hop in a path this may be an SCID alias and - /// may not refer to a channel in the public network graph. These aliases may also collide - /// with channels in the public network graph. - /// - /// If this is `Some`, then the corresponding channel should be avoided when the payment is - /// retried. May be `None` for older [`Event`] serializations. - short_channel_id: crate::c_types::derived::COption_u64Z, - }, - /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. - ProbeSuccessful { - /// The id returned by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash generated by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that was successful. - path: crate::lightning::routing::router::Path, - }, - /// Indicates that a probe payment we sent failed at an intermediary node on the path. - ProbeFailed { - /// The id returned by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash generated by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that failed. - path: crate::lightning::routing::router::Path, - /// The channel responsible for the failed probe. - /// - /// Note that for route hints or for the first hop in a path this may be an SCID alias and - /// may not refer to a channel in the public network graph. These aliases may also collide - /// with channels in the public network graph. - short_channel_id: crate::c_types::derived::COption_u64Z, - }, - /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at - /// a time in the future. - /// - /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - PendingHTLCsForwardable { - /// The minimum amount of time that should be waited prior to calling - /// process_pending_htlc_forwards. To increase the effort required to correlate payments, - /// you should wait a random amount of time in roughly the range (now + time_forwardable, - /// now + 5*time_forwardable). - time_forwardable: u64, - }, - /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if - /// you've encoded an intercept scid in the receiver's invoice route hints using - /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. - /// - /// [`ChannelManager::forward_intercepted_htlc`] or - /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See - /// their docs for more information. - /// - /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc - /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc - HTLCIntercepted { - /// An id to help LDK identify which HTLC is being forwarded or failed. - intercept_id: crate::c_types::ThirtyTwoBytes, - /// The fake scid that was programmed as the next hop's scid, generated using - /// [`ChannelManager::get_intercept_scid`]. - /// - /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - requested_next_hop_scid: u64, - /// The payment hash used for this HTLC. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// How many msats were received on the inbound edge of this HTLC. - inbound_amount_msat: u64, - /// How many msats the payer intended to route to the next node. Depending on the reason you are - /// intercepting this payment, you might take a fee by forwarding less than this amount. - /// - /// Note that LDK will NOT check that expected fees were factored into this value. You MUST - /// check that whatever fee you want has been included here or subtract it as required. Further, - /// LDK will not stop you from forwarding more than you received. - expected_outbound_amount_msat: u64, - }, - /// Used to indicate that an output which you should know how to spend was confirmed on chain - /// and is now spendable. - /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - /// counterparty spending them due to some kind of timeout. Thus, you need to store them - /// somewhere and spend them when you create on-chain transactions. - SpendableOutputs { - /// The outputs which you should store as spendable by you. - outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, - }, - /// This event is generated when a payment has been successfully forwarded through us and a - /// forwarding fee earned. - PaymentForwarded { - /// The incoming channel between the previous node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - prev_channel_id: crate::c_types::ThirtyTwoBytes, - /// The outgoing channel between the next node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - next_channel_id: crate::c_types::ThirtyTwoBytes, - /// The fee, in milli-satoshis, which was earned as a result of the payment. - /// - /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC - /// was pending, the amount the next hop claimed will have been rounded down to the nearest - /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still - /// claimed the full value in millisatoshis from the source. In this case, - /// `claim_from_onchain_tx` will be set. - /// - /// If the channel which sent us the payment has been force-closed, we will claim the funds - /// via an on-chain transaction. In that case we do not yet know the on-chain transaction - /// fees which we will spend and will instead set this to `None`. It is possible duplicate - /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is - /// `None`. - fee_earned_msat: crate::c_types::derived::COption_u64Z, - /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain - /// transaction. - claim_from_onchain_tx: bool, - /// The final amount forwarded, in milli-satoshis, after the fee is deducted. - /// - /// The caveat described above the `fee_earned_msat` field applies here as well. - outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z, - }, - /// Used to indicate that a channel with the given `channel_id` is being opened and pending - /// confirmation on-chain. - /// - /// This event is emitted when the funding transaction has been signed and is broadcast to the - /// network. For 0conf channels it will be immediately followed by the corresponding - /// [`Event::ChannelReady`] event. - ChannelPending { - /// The `channel_id` of the channel that is pending confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for an inbound channel. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The `temporary_channel_id` this channel used to be known by during channel establishment. - /// - /// Will be `None` for channels created prior to LDK version 0.0.115. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The `node_id` of the channel counterparty. - counterparty_node_id: crate::c_types::PublicKey, - /// The outpoint of the channel's funding transaction. - funding_txo: crate::lightning::chain::transaction::OutPoint, - }, - /// Used to indicate that a channel with the given `channel_id` is ready to - /// be used. This event is emitted either when the funding transaction has been confirmed - /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel - /// establishment. - ChannelReady { - /// The `channel_id` of the channel that is ready. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for an inbound channel. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The `node_id` of the channel counterparty. - counterparty_node_id: crate::c_types::PublicKey, - /// The features that this channel will operate with. - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, - }, - /// Used to indicate that a previously opened channel with the given `channel_id` is in the - /// process of closure. - ChannelClosed { - /// The `channel_id` of the channel which has been closed. Note that on-chain transactions - /// resolving the channel are likely still awaiting confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for inbound channels. - /// This may be zero for inbound channels serialized prior to 0.0.113 and will always be - /// zero for objects serialized with LDK versions prior to 0.0.102. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The reason the channel was closed. - reason: crate::lightning::events::ClosureReason, - }, - /// Used to indicate to the user that they can abandon the funding transaction and recycle the - /// inputs for another purpose. - DiscardFunding { - /// The channel_id of the channel which has been closed. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The full transaction received from the user - transaction: crate::c_types::Transaction, - }, - /// Indicates a request to open a new channel by a peer. - /// - /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the - /// request, call [`ChannelManager::force_close_without_broadcasting_txn`]. - /// - /// The event is only triggered when a new open channel request is received and the - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - OpenChannelRequest { - /// The temporary channel ID of the channel requested to be opened. - /// - /// When responding to the request, the `temporary_channel_id` should be passed - /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, - /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The node_id of the counterparty requesting to open the channel. - /// - /// When responding to the request, the `counterparty_node_id` should be passed - /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to - /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the - /// request. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - counterparty_node_id: crate::c_types::PublicKey, - /// The channel value of the requested channel. - funding_satoshis: u64, - /// Our starting balance in the channel if the request is accepted, in milli-satoshi. - push_msat: u64, - /// The features that this channel will operate with. If you reject the channel, a - /// well-behaved counterparty may automatically re-attempt the channel with a new set of - /// feature flags. - /// - /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, - /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - /// 0.0.106. - /// - /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, - /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - /// 0.0.107. Channels setting this type also need to get manually accepted via - /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], - /// or will be rejected otherwise. - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, - }, - /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to - /// forward it. - /// - /// Some scenarios where this event may be sent include: - /// * Insufficient capacity in the outbound channel - /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes - /// * When an unknown SCID is requested for forwarding a payment. - /// * Expected MPP amount has already been reached - /// * The HTLC has timed out - /// - /// This event, however, does not get generated if an HTLC fails to meet the forwarding - /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon). - HTLCHandlingFailed { - /// The channel over which the HTLC was received. - prev_channel_id: crate::c_types::ThirtyTwoBytes, - /// Destination of the HTLC that failed to be processed. - failed_next_destination: crate::lightning::events::HTLCDestination, - }, -} -use lightning::events::Event as EventImport; -pub(crate) type nativeEvent = EventImport; - -impl Event { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeEvent { - match self { - Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); - let mut output_script_nonref = Clone::clone(output_script); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - nativeEvent::FundingGenerationReady { - temporary_channel_id: temporary_channel_id_nonref.data, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - channel_value_satoshis: channel_value_satoshis_nonref, - output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()), - user_channel_id: user_channel_id_nonref.into(), - } - }, - Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut onion_fields_nonref = Clone::clone(onion_fields); - let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) }; - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = if via_channel_id_nonref.data == [0; 32] { None } else { Some( { via_channel_id_nonref.data }) }; - let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); - let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} }; - let mut claim_deadline_nonref = Clone::clone(claim_deadline); - let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None }; - nativeEvent::PaymentClaimable { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - onion_fields: local_onion_fields_nonref, - amount_msat: amount_msat_nonref, - purpose: purpose_nonref.into_native(), - via_channel_id: local_via_channel_id_nonref, - via_user_channel_id: local_via_user_channel_id_nonref, - claim_deadline: local_claim_deadline_nonref, - } - }, - Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - nativeEvent::PaymentClaimed { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - amount_msat: amount_msat_nonref, - purpose: purpose_nonref.into_native(), - } - }, - Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) }; - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); - let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None }; - nativeEvent::PaymentSent { - payment_id: local_payment_id_nonref, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - fee_paid_msat: local_fee_paid_msat_nonref, - } - }, - Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut reason_nonref = Clone::clone(reason); - let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} }; - nativeEvent::PaymentFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - reason: local_reason_nonref, - } - }, - Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) }; - let mut path_nonref = Clone::clone(path); - nativeEvent::PaymentPathSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: local_payment_hash_nonref, - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - } - }, - Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); - let mut failure_nonref = Clone::clone(failure); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; - nativeEvent::PaymentPathFailed { - payment_id: local_payment_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - payment_failed_permanently: payment_failed_permanently_nonref, - failure: failure_nonref.into_native(), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - short_channel_id: local_short_channel_id_nonref, - } - }, - Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - nativeEvent::ProbeSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - } - }, - Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; - nativeEvent::ProbeFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - short_channel_id: local_short_channel_id_nonref, - } - }, - Event::PendingHTLCsForwardable {ref time_forwardable, } => { - let mut time_forwardable_nonref = Clone::clone(time_forwardable); - nativeEvent::PendingHTLCsForwardable { - time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref), - } - }, - Event::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { - let mut intercept_id_nonref = Clone::clone(intercept_id); - let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); - let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); - nativeEvent::HTLCIntercepted { - intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data), - requested_next_hop_scid: requested_next_hop_scid_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - inbound_amount_msat: inbound_amount_msat_nonref, - expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, - } - }, - Event::SpendableOutputs {ref outputs, } => { - let mut outputs_nonref = Clone::clone(outputs); - let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); }; - nativeEvent::SpendableOutputs { - outputs: local_outputs_nonref, - } - }, - Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) }; - let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = if next_channel_id_nonref.data == [0; 32] { None } else { Some( { next_channel_id_nonref.data }) }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None }; - let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); - let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); - let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None }; - nativeEvent::PaymentForwarded { - prev_channel_id: local_prev_channel_id_nonref, - next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, - claim_from_onchain_tx: claim_from_onchain_tx_nonref, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, - } - }, - Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.data == [0; 32] { None } else { Some( { former_temporary_channel_id_nonref.data }) }; - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_txo_nonref = Clone::clone(funding_txo); - nativeEvent::ChannelPending { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - former_temporary_channel_id: local_former_temporary_channel_id_nonref, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), - } - }, - Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_type_nonref = Clone::clone(channel_type); - nativeEvent::ChannelReady { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, - } - }, - Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut reason_nonref = Clone::clone(reason); - nativeEvent::ChannelClosed { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - reason: reason_nonref.into_native(), - } - }, - Event::DiscardFunding {ref channel_id, ref transaction, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); - nativeEvent::DiscardFunding { - channel_id: channel_id_nonref.data, - transaction: transaction_nonref.into_bitcoin(), - } - }, - Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); - let mut push_msat_nonref = Clone::clone(push_msat); - let mut channel_type_nonref = Clone::clone(channel_type); - nativeEvent::OpenChannelRequest { - temporary_channel_id: temporary_channel_id_nonref.data, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - funding_satoshis: funding_satoshis_nonref, - push_msat: push_msat_nonref, - channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, - } - }, - Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); - nativeEvent::HTLCHandlingFailed { - prev_channel_id: prev_channel_id_nonref.data, - failed_next_destination: failed_next_destination_nonref.into_native(), - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeEvent { - match self { - Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { - nativeEvent::FundingGenerationReady { - temporary_channel_id: temporary_channel_id.data, - counterparty_node_id: counterparty_node_id.into_rust(), - channel_value_satoshis: channel_value_satoshis, - output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()), - user_channel_id: user_channel_id.into(), - } - }, - Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { - let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; - let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; - let mut local_via_channel_id = if via_channel_id.data == [0; 32] { None } else { Some( { via_channel_id.data }) }; - let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} }; - let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None }; - nativeEvent::PaymentClaimable { - receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - onion_fields: local_onion_fields, - amount_msat: amount_msat, - purpose: purpose.into_native(), - via_channel_id: local_via_channel_id, - via_user_channel_id: local_via_user_channel_id, - claim_deadline: local_claim_deadline, - } - }, - Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { - let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; - nativeEvent::PaymentClaimed { - receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - amount_msat: amount_msat, - purpose: purpose.into_native(), - } - }, - Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { - let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) }; - let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None }; - nativeEvent::PaymentSent { - payment_id: local_payment_id, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - fee_paid_msat: local_fee_paid_msat, - } - }, - Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { - let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} }; - nativeEvent::PaymentFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - reason: local_reason, - } - }, - Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; - nativeEvent::PaymentPathSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: local_payment_hash, - path: *unsafe { Box::from_raw(path.take_inner()) }, - } - }, - Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { - let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) }; - let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; - nativeEvent::PaymentPathFailed { - payment_id: local_payment_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - payment_failed_permanently: payment_failed_permanently, - failure: failure.into_native(), - path: *unsafe { Box::from_raw(path.take_inner()) }, - short_channel_id: local_short_channel_id, - } - }, - Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - nativeEvent::ProbeSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: *unsafe { Box::from_raw(path.take_inner()) }, - } - }, - Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; - nativeEvent::ProbeFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: *unsafe { Box::from_raw(path.take_inner()) }, - short_channel_id: local_short_channel_id, - } - }, - Event::PendingHTLCsForwardable {mut time_forwardable, } => { - nativeEvent::PendingHTLCsForwardable { - time_forwardable: core::time::Duration::from_secs(time_forwardable), - } - }, - Event::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { - nativeEvent::HTLCIntercepted { - intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data), - requested_next_hop_scid: requested_next_hop_scid, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - inbound_amount_msat: inbound_amount_msat, - expected_outbound_amount_msat: expected_outbound_amount_msat, - } - }, - Event::SpendableOutputs {mut outputs, } => { - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); }; - nativeEvent::SpendableOutputs { - outputs: local_outputs, - } - }, - Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) }; - let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) }; - let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None }; - let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None }; - nativeEvent::PaymentForwarded { - prev_channel_id: local_prev_channel_id, - next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, - claim_from_onchain_tx: claim_from_onchain_tx, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, - } - }, - Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = if former_temporary_channel_id.data == [0; 32] { None } else { Some( { former_temporary_channel_id.data }) }; - nativeEvent::ChannelPending { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - former_temporary_channel_id: local_former_temporary_channel_id, - counterparty_node_id: counterparty_node_id.into_rust(), - funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), - } - }, - Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { - nativeEvent::ChannelReady { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - counterparty_node_id: counterparty_node_id.into_rust(), - channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, - } - }, - Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { - nativeEvent::ChannelClosed { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - reason: reason.into_native(), - } - }, - Event::DiscardFunding {mut channel_id, mut transaction, } => { - nativeEvent::DiscardFunding { - channel_id: channel_id.data, - transaction: transaction.into_bitcoin(), - } - }, - Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { - nativeEvent::OpenChannelRequest { - temporary_channel_id: temporary_channel_id.data, - counterparty_node_id: counterparty_node_id.into_rust(), - funding_satoshis: funding_satoshis, - push_msat: push_msat, - channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, - } - }, - Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { - nativeEvent::HTLCHandlingFailed { - prev_channel_id: prev_channel_id.data, - failed_next_destination: failed_next_destination.into_native(), - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeEvent) -> Self { - match native { - nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); - let mut output_script_nonref = Clone::clone(output_script); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - channel_value_satoshis: channel_value_satoshis_nonref, - output_script: output_script_nonref.into_bytes().into(), - user_channel_id: user_channel_id_nonref.into(), - } - }, - nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut onion_fields_nonref = Clone::clone(onion_fields); - let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true }; - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id_nonref.unwrap()) } } }; - let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); - let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) }; - let mut claim_deadline_nonref = Clone::clone(claim_deadline); - let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline_nonref.unwrap() }) }; - Event::PaymentClaimable { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - onion_fields: local_onion_fields_nonref, - amount_msat: amount_msat_nonref, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), - via_channel_id: local_via_channel_id_nonref, - via_user_channel_id: local_via_user_channel_id_nonref, - claim_deadline: local_claim_deadline_nonref, - } - }, - nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - Event::PaymentClaimed { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - amount_msat: amount_msat_nonref, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), - } - }, - nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } }; - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); - let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat_nonref.unwrap() }) }; - Event::PaymentSent { - payment_id: local_payment_id_nonref, - payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - fee_paid_msat: local_fee_paid_msat_nonref, - } - }, - nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut reason_nonref = Clone::clone(reason); - let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) }; - Event::PaymentFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - reason: local_reason_nonref, - } - }, - nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } }; - let mut path_nonref = Clone::clone(path); - Event::PaymentPathSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: local_payment_hash_nonref, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - } - }, - nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); - let mut failure_nonref = Clone::clone(failure); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; - Event::PaymentPathFailed { - payment_id: local_payment_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - payment_failed_permanently: payment_failed_permanently_nonref, - failure: crate::lightning::events::PathFailure::native_into(failure_nonref), - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - short_channel_id: local_short_channel_id_nonref, - } - }, - nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - Event::ProbeSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - } - }, - nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; - Event::ProbeFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - short_channel_id: local_short_channel_id_nonref, - } - }, - nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => { - let mut time_forwardable_nonref = Clone::clone(time_forwardable); - Event::PendingHTLCsForwardable { - time_forwardable: time_forwardable_nonref.as_secs(), - } - }, - nativeEvent::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { - let mut intercept_id_nonref = Clone::clone(intercept_id); - let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); - let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); - Event::HTLCIntercepted { - intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id_nonref.0 }, - requested_next_hop_scid: requested_next_hop_scid_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - inbound_amount_msat: inbound_amount_msat_nonref, - expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, - } - }, - nativeEvent::SpendableOutputs {ref outputs, } => { - let mut outputs_nonref = Clone::clone(outputs); - let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; - Event::SpendableOutputs { - outputs: local_outputs_nonref.into(), - } - }, - nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } }; - let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id_nonref.unwrap()) } } }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) }; - let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); - let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); - let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) }; - Event::PaymentForwarded { - prev_channel_id: local_prev_channel_id_nonref, - next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, - claim_from_onchain_tx: claim_from_onchain_tx_nonref, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, - } - }, - nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id_nonref.unwrap()) } } }; - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_txo_nonref = Clone::clone(funding_txo); - Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - former_temporary_channel_id: local_former_temporary_channel_id_nonref, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo_nonref), - } - }, - nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_type_nonref = Clone::clone(channel_type); - Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, - } - }, - nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut reason_nonref = Clone::clone(reason); - Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), - } - }, - nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); - Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), - } - }, - nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); - let mut push_msat_nonref = Clone::clone(push_msat); - let mut channel_type_nonref = Clone::clone(channel_type); - Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - funding_satoshis: funding_satoshis_nonref, - push_msat: push_msat_nonref, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, - } - }, - nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); - Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref }, - failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref), - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeEvent) -> Self { - match native { - nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { - Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - channel_value_satoshis: channel_value_satoshis, - output_script: output_script.into_bytes().into(), - user_channel_id: user_channel_id.into(), - } - }, - nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { - let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; - let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; - let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id.unwrap()) } } }; - let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id.unwrap().into() }) }; - let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) }; - Event::PaymentClaimable { - receiver_node_id: local_receiver_node_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - onion_fields: local_onion_fields, - amount_msat: amount_msat, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), - via_channel_id: local_via_channel_id, - via_user_channel_id: local_via_user_channel_id, - claim_deadline: local_claim_deadline, - } - }, - nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { - let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; - Event::PaymentClaimed { - receiver_node_id: local_receiver_node_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - amount_msat: amount_msat, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), - } - }, - nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { - let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } }; - let mut local_fee_paid_msat = if fee_paid_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat.unwrap() }) }; - Event::PaymentSent { - payment_id: local_payment_id, - payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - fee_paid_msat: local_fee_paid_msat, - } - }, - nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { - let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) }; - Event::PaymentFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - reason: local_reason, - } - }, - nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } }; - Event::PaymentPathSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: local_payment_hash, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - } - }, - nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { - let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } }; - let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; - Event::PaymentPathFailed { - payment_id: local_payment_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - payment_failed_permanently: payment_failed_permanently, - failure: crate::lightning::events::PathFailure::native_into(failure), - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - short_channel_id: local_short_channel_id, - } - }, - nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - Event::ProbeSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - } - }, - nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; - Event::ProbeFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - short_channel_id: local_short_channel_id, - } - }, - nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => { - Event::PendingHTLCsForwardable { - time_forwardable: time_forwardable.as_secs(), - } - }, - nativeEvent::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { - Event::HTLCIntercepted { - intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id.0 }, - requested_next_hop_scid: requested_next_hop_scid, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - inbound_amount_msat: inbound_amount_msat, - expected_outbound_amount_msat: expected_outbound_amount_msat, - } - }, - nativeEvent::SpendableOutputs {mut outputs, } => { - let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; - Event::SpendableOutputs { - outputs: local_outputs.into(), - } - }, - nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id.unwrap()) } } }; - let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id.unwrap()) } } }; - let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) }; - let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) }; - Event::PaymentForwarded { - prev_channel_id: local_prev_channel_id, - next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, - claim_from_onchain_tx: claim_from_onchain_tx, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, - } - }, - nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id.unwrap()) } } }; - Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - former_temporary_channel_id: local_former_temporary_channel_id, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo), - } - }, - nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { - Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, - } - }, - nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { - Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - reason: crate::lightning::events::ClosureReason::native_into(reason), - } - }, - nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { - Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction), - } - }, - nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { - Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - funding_satoshis: funding_satoshis, - push_msat: push_msat, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, - } - }, - nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { - Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id }, - failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination), - } - }, - } - } -} -/// Frees any resources used by the Event -#[no_mangle] -pub extern "C" fn Event_free(this_ptr: Event) { } -/// Creates a copy of the Event -#[no_mangle] -pub extern "C" fn Event_clone(orig: &Event) -> Event { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new FundingGenerationReady-variant Event -pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: crate::c_types::U128) -> Event { - Event::FundingGenerationReady { - temporary_channel_id, - counterparty_node_id, - channel_value_satoshis, - output_script, - user_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentClaimable-variant Event -pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::ThirtyTwoBytes, via_user_channel_id: crate::c_types::derived::COption_u128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { - Event::PaymentClaimable { - receiver_node_id, - payment_hash, - onion_fields, - amount_msat, - purpose, - via_channel_id, - via_user_channel_id, - claim_deadline, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentClaimed-variant Event -pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose) -> Event { - Event::PaymentClaimed { - receiver_node_id, - payment_hash, - amount_msat, - purpose, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentSent-variant Event -pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentSent { - payment_id, - payment_preimage, - payment_hash, - fee_paid_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentFailed-variant Event -pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { - Event::PaymentFailed { - payment_id, - payment_hash, - reason, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentPathSuccessful-variant Event -pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { - Event::PaymentPathSuccessful { - payment_id, - payment_hash, - path, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentPathFailed-variant Event -pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::events::PathFailure, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentPathFailed { - payment_id, - payment_hash, - payment_failed_permanently, - failure, - path, - short_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new ProbeSuccessful-variant Event -pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { - Event::ProbeSuccessful { - payment_id, - payment_hash, - path, - } -} -#[no_mangle] -/// Utility method to constructs a new ProbeFailed-variant Event -pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { - Event::ProbeFailed { - payment_id, - payment_hash, - path, - short_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new PendingHTLCsForwardable-variant Event -pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event { - Event::PendingHTLCsForwardable { - time_forwardable, - } -} -#[no_mangle] -/// Utility method to constructs a new HTLCIntercepted-variant Event -pub extern "C" fn Event_htlcintercepted(intercept_id: crate::c_types::ThirtyTwoBytes, requested_next_hop_scid: u64, payment_hash: crate::c_types::ThirtyTwoBytes, inbound_amount_msat: u64, expected_outbound_amount_msat: u64) -> Event { - Event::HTLCIntercepted { - intercept_id, - requested_next_hop_scid, - payment_hash, - inbound_amount_msat, - expected_outbound_amount_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new SpendableOutputs-variant Event -pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ) -> Event { - Event::SpendableOutputs { - outputs, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentForwarded-variant Event -pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentForwarded { - prev_channel_id, - next_channel_id, - fee_earned_msat, - claim_from_onchain_tx, - outbound_amount_forwarded_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelPending-variant Event -pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { - Event::ChannelPending { - channel_id, - user_channel_id, - former_temporary_channel_id, - counterparty_node_id, - funding_txo, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelReady-variant Event -pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { - Event::ChannelReady { - channel_id, - user_channel_id, - counterparty_node_id, - channel_type, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelClosed-variant Event -pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason) -> Event { - Event::ChannelClosed { - channel_id, - user_channel_id, - reason, - } -} -#[no_mangle] -/// Utility method to constructs a new DiscardFunding-variant Event -pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event { - Event::DiscardFunding { - channel_id, - transaction, - } -} -#[no_mangle] -/// Utility method to constructs a new OpenChannelRequest-variant Event -pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { - Event::OpenChannelRequest { - temporary_channel_id, - counterparty_node_id, - funding_satoshis, - push_msat, - channel_type, - } -} -#[no_mangle] -/// Utility method to constructs a new HTLCHandlingFailed-variant Event -pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { - Event::HTLCHandlingFailed { - prev_channel_id, - failed_next_destination, - } -} -/// Checks if two Events contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the Event object into a byte array which can be read by Event_read -pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a Event from a byte array, created by Event_write -pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// An event generated by ChannelManager which indicates a message should be sent to a peer (or -/// broadcast to most peers). -/// These events are handled by PeerManager::process_events if you are using a PeerManager. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum MessageSendEvent { - /// Used to indicate that we've accepted a channel open and should send the accept_channel - /// message provided to the given peer. - SendAcceptChannel { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::AcceptChannel, - }, - /// Used to indicate that we've initiated a channel open and should send the open_channel - /// message provided to the given peer. - SendOpenChannel { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::OpenChannel, - }, - /// Used to indicate that a funding_created message should be sent to the peer with the given node_id. - SendFundingCreated { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::FundingCreated, - }, - /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id. - SendFundingSigned { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::FundingSigned, - }, - /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id. - SendChannelReady { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The channel_ready message which should be sent. - msg: crate::lightning::ln::msgs::ChannelReady, - }, - /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. - SendAnnouncementSignatures { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The announcement_signatures message which should be sent. - msg: crate::lightning::ln::msgs::AnnouncementSignatures, - }, - /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed - /// message should be sent to the peer with the given node_id. - UpdateHTLCs { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The update messages which should be sent. ALL messages in the struct should be sent! - updates: crate::lightning::ln::msgs::CommitmentUpdate, - }, - /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. - SendRevokeAndACK { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::RevokeAndACK, - }, - /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id. - SendClosingSigned { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::ClosingSigned, - }, - /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. - SendShutdown { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::Shutdown, - }, - /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. - SendChannelReestablish { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::ChannelReestablish, - }, - /// Used to send a channel_announcement and channel_update to a specific peer, likely on - /// initial connection to ensure our peers know about our channels. - SendChannelAnnouncement { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The channel_announcement which should be sent. - msg: crate::lightning::ln::msgs::ChannelAnnouncement, - /// The followup channel_update which should be sent. - update_msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a channel_announcement and channel_update should be broadcast to all - /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). - /// - /// Note that after doing so, you very likely (unless you did so very recently) want to - /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This - /// ensures that any nodes which see our channel_announcement also have a relevant - /// node_announcement, including relevant feature flags which may be important for routing - /// through or to us. - /// - /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement - BroadcastChannelAnnouncement { - /// The channel_announcement which should be sent. - msg: crate::lightning::ln::msgs::ChannelAnnouncement, - /// The followup channel_update which should be sent. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - update_msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a channel_update should be broadcast to all peers. - BroadcastChannelUpdate { - /// The channel_update which should be sent. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a node_announcement should be broadcast to all peers. - BroadcastNodeAnnouncement { - /// The node_announcement which should be sent. - msg: crate::lightning::ln::msgs::NodeAnnouncement, - }, - /// Used to indicate that a channel_update should be sent to a single peer. - /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a - /// private channel and we shouldn't be informing all of our peers of channel parameters. - SendChannelUpdate { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The channel_update which should be sent. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Broadcast an error downstream to be handled - HandleError { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The action which should be taken. - action: crate::lightning::ln::msgs::ErrorAction, - }, - /// Query a peer for channels with funding transaction UTXOs in a block range. - SendChannelRangeQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_channel_range which should be sent. - msg: crate::lightning::ln::msgs::QueryChannelRange, - }, - /// Request routing gossip messages from a peer for a list of channels identified by - /// their short_channel_ids. - SendShortIdsQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_short_channel_ids which should be sent. - msg: crate::lightning::ln::msgs::QueryShortChannelIds, - }, - /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - /// emitted during processing of the query. - SendReplyChannelRange { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The reply_channel_range which should be sent. - msg: crate::lightning::ln::msgs::ReplyChannelRange, - }, - /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to - /// enable receiving gossip messages from the peer. - SendGossipTimestampFilter { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The gossip_timestamp_filter which should be sent. - msg: crate::lightning::ln::msgs::GossipTimestampFilter, - }, -} -use lightning::events::MessageSendEvent as MessageSendEventImport; -pub(crate) type nativeMessageSendEvent = MessageSendEventImport; - -impl MessageSendEvent { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeMessageSendEvent { - match self { - MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendAcceptChannel { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendOpenChannel { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendFundingCreated { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendFundingSigned { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelReady { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendAnnouncementSignatures { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut updates_nonref = Clone::clone(updates); - nativeMessageSendEvent::UpdateHTLCs { - node_id: node_id_nonref.into_rust(), - updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendRevokeAndACK { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendClosingSigned { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendShutdown {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendShutdown { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelReestablish { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - nativeMessageSendEvent::SendChannelAnnouncement { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - let mut local_update_msg_nonref = if update_msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg_nonref.take_inner()) } }) }; - nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - update_msg: local_update_msg_nonref, - } - }, - MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelUpdate { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::HandleError {ref node_id, ref action, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut action_nonref = Clone::clone(action); - nativeMessageSendEvent::HandleError { - node_id: node_id_nonref.into_rust(), - action: action_nonref.into_native(), - } - }, - MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendGossipTimestampFilter { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeMessageSendEvent { - match self { - MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendAcceptChannel { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendOpenChannel { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingCreated { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelReady { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendAnnouncementSignatures { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { - nativeMessageSendEvent::UpdateHTLCs { - node_id: node_id.into_rust(), - updates: *unsafe { Box::from_raw(updates.take_inner()) }, - } - }, - MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendRevokeAndACK { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendClosingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShutdown { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelReestablish { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { - nativeMessageSendEvent::SendChannelAnnouncement { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { - let mut local_update_msg = if update_msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg.take_inner()) } }) }; - nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - update_msg: local_update_msg, - } - }, - MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelUpdate { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::HandleError {mut node_id, mut action, } => { - nativeMessageSendEvent::HandleError { - node_id: node_id.into_rust(), - action: action.into_native(), - } - }, - MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendGossipTimestampFilter { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self { - match native { - nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendAcceptChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendOpenChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendFundingCreated { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendFundingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelReady { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendAnnouncementSignatures { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut updates_nonref = Clone::clone(updates); - MessageSendEvent::UpdateHTLCs { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendRevokeAndACK { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendClosingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendShutdown { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelReestablish { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - MessageSendEvent::SendChannelAnnouncement { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - let mut local_update_msg_nonref = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg_nonref.unwrap())) } }, is_owned: true }; - MessageSendEvent::BroadcastChannelAnnouncement { - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - update_msg: local_update_msg_nonref, - } - }, - nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::BroadcastChannelUpdate { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::BroadcastNodeAnnouncement { - msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelUpdate { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::HandleError {ref node_id, ref action, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut action_nonref = Clone::clone(action); - MessageSendEvent::HandleError { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendGossipTimestampFilter { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self { - match native { - nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { - MessageSendEvent::SendAcceptChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { - MessageSendEvent::SendOpenChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { - MessageSendEvent::SendFundingCreated { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { - MessageSendEvent::SendFundingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelReady { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { - MessageSendEvent::SendAnnouncementSignatures { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { - MessageSendEvent::UpdateHTLCs { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true }, - } - }, - nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { - MessageSendEvent::SendRevokeAndACK { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { - MessageSendEvent::SendClosingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => { - MessageSendEvent::SendShutdown { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelReestablish { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { - MessageSendEvent::SendChannelAnnouncement { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { - let mut local_update_msg = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg.unwrap())) } }, is_owned: true }; - MessageSendEvent::BroadcastChannelAnnouncement { - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - update_msg: local_update_msg, - } - }, - nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => { - MessageSendEvent::BroadcastChannelUpdate { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { - MessageSendEvent::BroadcastNodeAnnouncement { - msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelUpdate { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::HandleError {mut node_id, mut action, } => { - MessageSendEvent::HandleError { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - action: crate::lightning::ln::msgs::ErrorAction::native_into(action), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { - MessageSendEvent::SendGossipTimestampFilter { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - } - } -} -/// Frees any resources used by the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { } -/// Creates a copy of the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent { - MessageSendEvent::SendAcceptChannel { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent { - MessageSendEvent::SendOpenChannel { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent { - MessageSendEvent::SendFundingCreated { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent { - MessageSendEvent::SendFundingSigned { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelReady-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent { - MessageSendEvent::SendChannelReady { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent { - MessageSendEvent::SendAnnouncementSignatures { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent { - MessageSendEvent::UpdateHTLCs { - node_id, - updates, - } -} -#[no_mangle] -/// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent { - MessageSendEvent::SendRevokeAndACK { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent { - MessageSendEvent::SendClosingSigned { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendShutdown-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent { - MessageSendEvent::SendShutdown { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent { - MessageSendEvent::SendChannelReestablish { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::SendChannelAnnouncement { - node_id, - msg, - update_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::BroadcastChannelAnnouncement { - msg, - update_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::BroadcastChannelUpdate { - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent { - MessageSendEvent::BroadcastNodeAnnouncement { - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::SendChannelUpdate { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new HandleError-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent { - MessageSendEvent::HandleError { - node_id, - action, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent { - MessageSendEvent::SendChannelRangeQuery { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent { - MessageSendEvent::SendShortIdsQuery { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent { - MessageSendEvent::SendReplyChannelRange { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent { - MessageSendEvent::SendGossipTimestampFilter { - node_id, - msg, - } -} -/// A trait indicating an object may generate message send events -#[repr(C)] -pub struct MessageSendEventsProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the list of pending events which were generated by previous actions, clearing the list - /// in the process. - #[must_use] - pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for MessageSendEventsProvider {} -unsafe impl Sync for MessageSendEventsProvider {} -#[no_mangle] -pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider { - MessageSendEventsProvider { - this_arg: orig.this_arg, - get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider; -impl rustMessageSendEventsProvider for MessageSendEventsProvider { - fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for MessageSendEventsProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { } -impl Drop for MessageSendEventsProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait indicating an object may generate onion messages to send -#[repr(C)] -pub struct OnionMessageProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the next pending onion message for the peer with the given node id. - /// - /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for OnionMessageProvider {} -unsafe impl Sync for OnionMessageProvider {} -#[no_mangle] -pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider { - OnionMessageProvider { - this_arg: orig.this_arg, - next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::OnionMessageProvider as rustOnionMessageProvider; -impl rustOnionMessageProvider for OnionMessageProvider { - fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { - let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id)); - let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for OnionMessageProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { } -impl Drop for OnionMessageProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait indicating an object may generate events. -/// -/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. -/// -/// Implementations of this trait may also feature an async version of event handling, as shown with -/// [`ChannelManager::process_pending_events_async`] and -/// [`ChainMonitor::process_pending_events_async`]. -/// -/// # Requirements -/// -/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending -/// event since the last invocation. -/// -/// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s -/// and replay any unhandled events on startup. An [`Event`] is considered handled when -/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any -/// relevant changes to disk *before* returning. -/// -/// Further, because an application may crash between an [`Event`] being handled and the -/// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in -/// effect, [`Event`]s may be replayed. -/// -/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to -/// consult the provider's documentation on the implication of processing events and how a handler -/// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and -/// [`ChainMonitor::process_pending_events`]). -/// -/// (C-not implementable) As there is likely no reason for a user to implement this trait on their -/// own type(s). -/// -/// [`process_pending_events`]: Self::process_pending_events -/// [`handle_event`]: EventHandler::handle_event -/// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events -/// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events -/// [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async -/// [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async -#[repr(C)] -pub struct EventsProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Processes any events generated since the last call using the given event handler. - /// - /// See the trait-level documentation for requirements. - pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EventsProvider {} -unsafe impl Sync for EventsProvider {} -#[no_mangle] -pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider { - EventsProvider { - this_arg: orig.this_arg, - process_pending_events: Clone::clone(&orig.process_pending_events), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::EventsProvider as rustEventsProvider; -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { } -impl Drop for EventsProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait implemented for objects handling events from [`EventsProvider`]. -/// -/// An async variation also exists for implementations of [`EventsProvider`] that support async -/// event handling. The async event handler should satisfy the generic bounds: `F: -/// core::future::Future, H: Fn(Event) -> F`. -#[repr(C)] -pub struct EventHandler { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Handles the given [`Event`]. - /// - /// See [`EventsProvider`] for details that must be considered when implementing this method. - pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EventHandler {} -unsafe impl Sync for EventHandler {} -#[no_mangle] -pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler { - EventHandler { - this_arg: orig.this_arg, - handle_event: Clone::clone(&orig.handle_event), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::EventHandler as rustEventHandler; -impl rustEventHandler for EventHandler { - fn handle_event(&self, mut event: lightning::events::Event) { - (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)) - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EventHandler { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { } -impl Drop for EventHandler { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} diff --git a/lightning-c-bindings/src/lightning/events/bump_transaction.rs b/lightning-c-bindings/src/lightning/events/bump_transaction.rs new file mode 100644 index 0000000..0ff12a5 --- /dev/null +++ b/lightning-c-bindings/src/lightning/events/bump_transaction.rs @@ -0,0 +1,1525 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Utilities for bumping transactions originating from [`Event`]s. +//! +//! [`Event`]: crate::events::Event + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::events::bump_transaction::ChannelDerivationParameters as nativeChannelDerivationParametersImport; +pub(crate) type nativeChannelDerivationParameters = nativeChannelDerivationParametersImport; + +/// The parameters required to derive a channel signer via [`SignerProvider`]. +#[must_use] +#[repr(C)] +pub struct ChannelDerivationParameters { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelDerivationParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelDerivationParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelDerivationParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_free(this_obj: ChannelDerivationParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelDerivationParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDerivationParameters) }; +} +#[allow(unused)] +impl ChannelDerivationParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDerivationParameters { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDerivationParameters { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelDerivationParameters { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The value in satoshis of the channel we're attempting to spend the anchor output of. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_get_value_satoshis(this_ptr: &ChannelDerivationParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().value_satoshis; + *inner_val +} +/// The value in satoshis of the channel we're attempting to spend the anchor output of. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_set_value_satoshis(this_ptr: &mut ChannelDerivationParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_satoshis = val; +} +/// The unique identifier to re-derive the signer for the associated channel. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_get_keys_id(this_ptr: &ChannelDerivationParameters) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().keys_id; + inner_val +} +/// The unique identifier to re-derive the signer for the associated channel. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_set_keys_id(this_ptr: &mut ChannelDerivationParameters, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys_id = val.data; +} +/// The necessary channel parameters that need to be provided to the re-derived signer through +/// [`ChannelSigner::provide_channel_parameters`]. +/// +/// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_get_transaction_parameters(this_ptr: &ChannelDerivationParameters) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().transaction_parameters; + crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false } +} +/// The necessary channel parameters that need to be provided to the re-derived signer through +/// [`ChannelSigner::provide_channel_parameters`]. +/// +/// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_set_transaction_parameters(this_ptr: &mut ChannelDerivationParameters, mut val: crate::lightning::ln::chan_utils::ChannelTransactionParameters) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.transaction_parameters = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new ChannelDerivationParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_new(mut value_satoshis_arg: u64, mut keys_id_arg: crate::c_types::ThirtyTwoBytes, mut transaction_parameters_arg: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> ChannelDerivationParameters { + ChannelDerivationParameters { inner: ObjOps::heap_alloc(nativeChannelDerivationParameters { + value_satoshis: value_satoshis_arg, + keys_id: keys_id_arg.data, + transaction_parameters: *unsafe { Box::from_raw(transaction_parameters_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for ChannelDerivationParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelDerivationParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelDerivationParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDerivationParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelDerivationParameters +pub extern "C" fn ChannelDerivationParameters_clone(orig: &ChannelDerivationParameters) -> ChannelDerivationParameters { + orig.clone() +} +/// Checks if two ChannelDerivationParameterss 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. +#[no_mangle] +pub extern "C" fn ChannelDerivationParameters_eq(a: &ChannelDerivationParameters, b: &ChannelDerivationParameters) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::events::bump_transaction::AnchorDescriptor as nativeAnchorDescriptorImport; +pub(crate) type nativeAnchorDescriptor = nativeAnchorDescriptorImport; + +/// A descriptor used to sign for a commitment transaction's anchor output. +#[must_use] +#[repr(C)] +pub struct AnchorDescriptor { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeAnchorDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for AnchorDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_free(this_obj: AnchorDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AnchorDescriptor_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAnchorDescriptor) }; +} +#[allow(unused)] +impl AnchorDescriptor { + pub(crate) fn get_native_ref(&self) -> &'static nativeAnchorDescriptor { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAnchorDescriptor { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeAnchorDescriptor { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The parameters required to derive the signer for the anchor input. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_get_channel_derivation_parameters(this_ptr: &AnchorDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters; + crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false } +} +/// The parameters required to derive the signer for the anchor input. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_set_channel_derivation_parameters(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The transaction input's outpoint corresponding to the commitment transaction's anchor +/// output. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_get_outpoint(this_ptr: &AnchorDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + crate::c_types::bitcoin_to_C_outpoint(inner_val) +} +/// The transaction input's outpoint corresponding to the commitment transaction's anchor +/// output. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_set_outpoint(this_ptr: &mut AnchorDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val); +} +/// Constructs a new AnchorDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_new(mut channel_derivation_parameters_arg: crate::lightning::events::bump_transaction::ChannelDerivationParameters, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint) -> AnchorDescriptor { + AnchorDescriptor { inner: ObjOps::heap_alloc(nativeAnchorDescriptor { + channel_derivation_parameters: *unsafe { Box::from_raw(channel_derivation_parameters_arg.take_inner()) }, + outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg), + }), is_owned: true } +} +impl Clone for AnchorDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAnchorDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AnchorDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAnchorDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the AnchorDescriptor +pub extern "C" fn AnchorDescriptor_clone(orig: &AnchorDescriptor) -> AnchorDescriptor { + orig.clone() +} +/// Checks if two AnchorDescriptors 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. +#[no_mangle] +pub extern "C" fn AnchorDescriptor_eq(a: &AnchorDescriptor, b: &AnchorDescriptor) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Returns the UTXO to be spent by the anchor input, which can be obtained via +/// [`Self::unsigned_tx_input`]. +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxOut { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo(); + crate::c_types::TxOut::from_rust(&ret) +} + +/// Returns the unsigned transaction input spending the anchor output in the commitment +/// transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::TxIn { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input(); + crate::c_types::TxIn::from_rust(&ret) +} + +/// Returns the witness script of the anchor output in the commitment transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor) -> crate::c_types::derived::CVec_u8Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script(); + ret.into_bytes().into() +} + +/// Returns the fully signed witness required to spend the anchor output in the commitment +/// transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, mut signature: crate::c_types::Signature) -> crate::c_types::Witness { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust()); + crate::c_types::Witness::from_bitcoin(&ret) +} + +/// Derives the channel signer required to sign the anchor input. +#[must_use] +#[no_mangle] +pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); + Into::into(ret) +} + + +use lightning::events::bump_transaction::HTLCDescriptor as nativeHTLCDescriptorImport; +pub(crate) type nativeHTLCDescriptor = nativeHTLCDescriptorImport; + +/// A descriptor used to sign for a commitment transaction's HTLC output. +#[must_use] +#[repr(C)] +pub struct HTLCDescriptor { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeHTLCDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for HTLCDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_free(this_obj: HTLCDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn HTLCDescriptor_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHTLCDescriptor) }; +} +#[allow(unused)] +impl HTLCDescriptor { + pub(crate) fn get_native_ref(&self) -> &'static nativeHTLCDescriptor { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHTLCDescriptor { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeHTLCDescriptor { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The parameters required to derive the signer for the HTLC input. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_channel_derivation_parameters(this_ptr: &HTLCDescriptor) -> crate::lightning::events::bump_transaction::ChannelDerivationParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_derivation_parameters; + crate::lightning::events::bump_transaction::ChannelDerivationParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::events::bump_transaction::ChannelDerivationParameters<>) as *mut _) }, is_owned: false } +} +/// The parameters required to derive the signer for the HTLC input. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_channel_derivation_parameters(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::events::bump_transaction::ChannelDerivationParameters) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The number of the commitment transaction in which the HTLC output lives. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_per_commitment_number(this_ptr: &HTLCDescriptor) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_number; + *inner_val +} +/// The number of the commitment transaction in which the HTLC output lives. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_per_commitment_number(this_ptr: &mut HTLCDescriptor, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_number = val; +} +/// The key tweak corresponding to the number of the commitment transaction in which the HTLC +/// output lives. This tweak is applied to all the basepoints for both parties in the channel to +/// arrive at unique keys per commitment. +/// +/// See for more info. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_per_commitment_point(this_ptr: &HTLCDescriptor) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The key tweak corresponding to the number of the commitment transaction in which the HTLC +/// output lives. This tweak is applied to all the basepoints for both parties in the channel to +/// arrive at unique keys per commitment. +/// +/// See for more info. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_per_commitment_point(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust(); +} +/// The details of the HTLC as it appears in the commitment transaction. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_htlc(this_ptr: &HTLCDescriptor) -> crate::lightning::ln::chan_utils::HTLCOutputInCommitment { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc; + crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false } +} +/// The details of the HTLC as it appears in the commitment transaction. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_htlc(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be +/// taken. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_preimage(this_ptr: &HTLCDescriptor) -> crate::c_types::derived::COption_PaymentPreimageZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().preimage; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_PaymentPreimageZ::None } else { crate::c_types::derived::COption_PaymentPreimageZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) }; + local_inner_val +} +/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be +/// taken. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_preimage(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::derived::COption_PaymentPreimageZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ val_opt.take() }.data) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.preimage = local_val; +} +/// The counterparty's signature required to spend the HTLC output. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_counterparty_sig(this_ptr: &HTLCDescriptor) -> crate::c_types::Signature { + let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_sig; + crate::c_types::Signature::from_rust(&inner_val) +} +/// The counterparty's signature required to spend the HTLC output. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_counterparty_sig(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::Signature) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_sig = val.into_rust(); +} +impl Clone for HTLCDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeHTLCDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn HTLCDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the HTLCDescriptor +pub extern "C" fn HTLCDescriptor_clone(orig: &HTLCDescriptor) -> HTLCDescriptor { + orig.clone() +} +/// Checks if two HTLCDescriptors 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. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_eq(a: &HTLCDescriptor, b: &HTLCDescriptor) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint +/// being spent by the HTLC input in the HTLC transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_outpoint(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.outpoint(); + crate::c_types::bitcoin_to_C_outpoint(&ret) +} + +/// Returns the UTXO to be spent by the HTLC input, which can be obtained via +/// [`Self::unsigned_tx_input`]. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_previous_utxo(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.previous_utxo(secp256k1::global::SECP256K1); + crate::c_types::TxOut::from_rust(&ret) +} + +/// Returns the unsigned transaction input spending the HTLC output in the commitment +/// transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_unsigned_tx_input(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxIn { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsigned_tx_input(); + crate::c_types::TxIn::from_rust(&ret) +} + +/// Returns the delayed output created as a result of spending the HTLC output in the commitment +/// transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_tx_output(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::TxOut { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_output(secp256k1::global::SECP256K1); + crate::c_types::TxOut::from_rust(&ret) +} + +/// Returns the witness script of the HTLC output in the commitment transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CVec_u8Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.witness_script(secp256k1::global::SECP256K1); + ret.into_bytes().into() +} + +/// Returns the fully signed witness required to spend the HTLC output in the commitment +/// transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, mut signature: crate::c_types::Signature, mut witness_script: crate::c_types::u8slice) -> crate::c_types::Witness { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), &::bitcoin::blockdata::script::Script::from(Vec::from(witness_script.to_slice()))); + crate::c_types::Witness::from_bitcoin(&ret) +} + +/// Derives the channel signer required to sign the HTLC input. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); + Into::into(ret) +} + +/// Represents the different types of transactions, originating from LDK, to be bumped. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum BumpTransactionEvent { + /// Indicates that a channel featuring anchor outputs is to be closed by broadcasting the local + /// commitment transaction. Since commitment transactions have a static feerate pre-agreed upon, + /// they may need additional fees to be attached through a child transaction using the popular + /// [Child-Pays-For-Parent](https://bitcoinops.org/en/topics/cpfp) fee bumping technique. This + /// child transaction must include the anchor input described within `anchor_descriptor` along + /// with additional inputs to meet the target feerate. Failure to meet the target feerate + /// decreases the confirmation odds of the transaction package (which includes the commitment + /// and child anchor transactions), possibly resulting in a loss of funds. Once the transaction + /// is constructed, it must be fully signed for and broadcast by the consumer of the event + /// along with the `commitment_tx` enclosed. Note that the `commitment_tx` must always be + /// broadcast first, as the child anchor transaction depends on it. + /// + /// The consumer should be able to sign for any of the additional inputs included within the + /// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be + /// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature + /// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be + /// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the + /// full witness required to spend. + /// + /// It is possible to receive more than one instance of this event if a valid child anchor + /// transaction is never broadcast or is but not with a sufficient fee to be mined. Care should + /// be taken by the consumer of the event to ensure any future iterations of the child anchor + /// transaction adhere to the [Replace-By-Fee + /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md) + /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of + /// these events is not user-controlled, users may ignore/drop the event if they are no longer + /// able to commit external confirmed funds to the child anchor transaction. + /// + /// The set of `pending_htlcs` on the commitment transaction to be broadcast can be inspected to + /// determine whether a significant portion of the channel's funds are allocated to HTLCs, + /// enabling users to make their own decisions regarding the importance of the commitment + /// transaction's confirmation. Note that this is not required, but simply exists as an option + /// for users to override LDK's behavior. On commitments with no HTLCs (indicated by those with + /// an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to + /// be not urgent. + /// + /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner + /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::EcdsaChannelSigner::sign_holder_anchor_input + /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness + ChannelClose { + /// The unique identifier for the claim of the anchor output in the commitment transaction. + /// + /// The identifier must map to the set of external UTXOs assigned to the claim, such that + /// they can be reused when a new claim with the same identifier needs to be made, resulting + /// in a fee-bumping attempt. + claim_id: crate::c_types::ThirtyTwoBytes, + /// The target feerate that the transaction package, which consists of the commitment + /// transaction and the to-be-crafted child anchor transaction, must meet. + package_target_feerate_sat_per_1000_weight: u32, + /// The channel's commitment transaction to bump the fee of. This transaction should be + /// broadcast along with the anchor transaction constructed as a result of consuming this + /// event. + commitment_tx: crate::c_types::Transaction, + /// The absolute fee in satoshis of the commitment transaction. This can be used along the + /// with weight of the commitment transaction to determine its feerate. + commitment_tx_fee_satoshis: u64, + /// The descriptor to sign the anchor input of the anchor transaction constructed as a + /// result of consuming this event. + anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, + /// The set of pending HTLCs on the commitment transaction that need to be resolved once the + /// commitment transaction confirms. + pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ, + }, + /// Indicates that a channel featuring anchor outputs has unilaterally closed on-chain by a + /// holder commitment transaction and its HTLC(s) need to be resolved on-chain. With the + /// zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC + /// transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached + /// for a timely confirmation within the chain. These additional inputs and/or outputs must be + /// appended to the resulting HTLC transaction to meet the target feerate. Failure to meet the + /// target feerate decreases the confirmation odds of the transaction, possibly resulting in a + /// loss of funds. Once the transaction meets the target feerate, it must be signed for and + /// broadcast by the consumer of the event. + /// + /// The consumer should be able to sign for any of the non-HTLC inputs added to the resulting + /// HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived + /// through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be + /// computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be + /// provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required + /// to spend. + /// + /// It is possible to receive more than one instance of this event if a valid HTLC transaction + /// is never broadcast or is but not with a sufficient fee to be mined. Care should be taken by + /// the consumer of the event to ensure any future iterations of the HTLC transaction adhere to + /// the [Replace-By-Fee + /// rules](https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md) + /// for fee bumps to be accepted into the mempool, and eventually the chain. As the frequency of + /// these events is not user-controlled, users may ignore/drop the event if either they are no + /// longer able to commit external confirmed funds to the HTLC transaction or the fee committed + /// to the HTLC transaction is greater in value than the HTLCs being claimed. + /// + /// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner + /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction + /// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness + HTLCResolution { + /// The unique identifier for the claim of the HTLCs in the confirmed commitment + /// transaction. + /// + /// The identifier must map to the set of external UTXOs assigned to the claim, such that + /// they can be reused when a new claim with the same identifier needs to be made, resulting + /// in a fee-bumping attempt. + claim_id: crate::c_types::ThirtyTwoBytes, + /// The target feerate that the resulting HTLC transaction must meet. + target_feerate_sat_per_1000_weight: u32, + /// The set of pending HTLCs on the confirmed commitment that need to be claimed, preferably + /// by the same transaction. + htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, + /// The locktime required for the resulting HTLC transaction. + tx_lock_time: u32, + }, +} +use lightning::events::bump_transaction::BumpTransactionEvent as BumpTransactionEventImport; +pub(crate) type nativeBumpTransactionEvent = BumpTransactionEventImport; + +impl BumpTransactionEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBumpTransactionEvent { + match self { + BumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + let mut claim_id_nonref = Clone::clone(claim_id); + let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight); + let mut commitment_tx_nonref = Clone::clone(commitment_tx); + let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis); + let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor); + let mut pending_htlcs_nonref = Clone::clone(pending_htlcs); + let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.into_rust().drain(..) { local_pending_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeBumpTransactionEvent::ChannelClose { + claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data), + package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref, + commitment_tx: commitment_tx_nonref.into_bitcoin(), + commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref, + anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor_nonref.take_inner()) }, + pending_htlcs: local_pending_htlcs_nonref, + } + }, + BumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + let mut claim_id_nonref = Clone::clone(claim_id); + let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight); + let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors); + let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.into_rust().drain(..) { local_htlc_descriptors_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut tx_lock_time_nonref = Clone::clone(tx_lock_time); + nativeBumpTransactionEvent::HTLCResolution { + claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data), + target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref, + htlc_descriptors: local_htlc_descriptors_nonref, + tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time_nonref), + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBumpTransactionEvent { + match self { + BumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { + let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.into_rust().drain(..) { local_pending_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeBumpTransactionEvent::ChannelClose { + claim_id: ::lightning::chain::ClaimId(claim_id.data), + package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight, + commitment_tx: commitment_tx.into_bitcoin(), + commitment_tx_fee_satoshis: commitment_tx_fee_satoshis, + anchor_descriptor: *unsafe { Box::from_raw(anchor_descriptor.take_inner()) }, + pending_htlcs: local_pending_htlcs, + } + }, + BumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { + let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.into_rust().drain(..) { local_htlc_descriptors.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeBumpTransactionEvent::HTLCResolution { + claim_id: ::lightning::chain::ClaimId(claim_id.data), + target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight, + htlc_descriptors: local_htlc_descriptors, + tx_lock_time: ::bitcoin::PackedLockTime(tx_lock_time), + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeBumpTransactionEvent) -> Self { + match native { + nativeBumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + let mut claim_id_nonref = Clone::clone(claim_id); + let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight); + let mut commitment_tx_nonref = Clone::clone(commitment_tx); + let mut commitment_tx_fee_satoshis_nonref = Clone::clone(commitment_tx_fee_satoshis); + let mut anchor_descriptor_nonref = Clone::clone(anchor_descriptor); + let mut pending_htlcs_nonref = Clone::clone(pending_htlcs); + let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.drain(..) { local_pending_htlcs_nonref.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + BumpTransactionEvent::ChannelClose { + claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 }, + package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref, + commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx_nonref), + commitment_tx_fee_satoshis: commitment_tx_fee_satoshis_nonref, + anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor_nonref), is_owned: true }, + pending_htlcs: local_pending_htlcs_nonref.into(), + } + }, + nativeBumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + let mut claim_id_nonref = Clone::clone(claim_id); + let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight); + let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors); + let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.drain(..) { local_htlc_descriptors_nonref.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut tx_lock_time_nonref = Clone::clone(tx_lock_time); + BumpTransactionEvent::HTLCResolution { + claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 }, + target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref, + htlc_descriptors: local_htlc_descriptors_nonref.into(), + tx_lock_time: tx_lock_time_nonref.0, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBumpTransactionEvent) -> Self { + match native { + nativeBumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { + let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.drain(..) { local_pending_htlcs.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + BumpTransactionEvent::ChannelClose { + claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, + package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight, + commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx), + commitment_tx_fee_satoshis: commitment_tx_fee_satoshis, + anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor { inner: ObjOps::heap_alloc(anchor_descriptor), is_owned: true }, + pending_htlcs: local_pending_htlcs.into(), + } + }, + nativeBumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { + let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.drain(..) { local_htlc_descriptors.push( { crate::lightning::events::bump_transaction::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + BumpTransactionEvent::HTLCResolution { + claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, + target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight, + htlc_descriptors: local_htlc_descriptors.into(), + tx_lock_time: tx_lock_time.0, + } + }, + } + } +} +/// Frees any resources used by the BumpTransactionEvent +#[no_mangle] +pub extern "C" fn BumpTransactionEvent_free(this_ptr: BumpTransactionEvent) { } +/// Creates a copy of the BumpTransactionEvent +#[no_mangle] +pub extern "C" fn BumpTransactionEvent_clone(orig: &BumpTransactionEvent) -> BumpTransactionEvent { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new ChannelClose-variant BumpTransactionEvent +pub extern "C" fn BumpTransactionEvent_channel_close(claim_id: crate::c_types::ThirtyTwoBytes, package_target_feerate_sat_per_1000_weight: u32, commitment_tx: crate::c_types::Transaction, commitment_tx_fee_satoshis: u64, anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> BumpTransactionEvent { + BumpTransactionEvent::ChannelClose { + claim_id, + package_target_feerate_sat_per_1000_weight, + commitment_tx, + commitment_tx_fee_satoshis, + anchor_descriptor, + pending_htlcs, + } +} +#[no_mangle] +/// Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent +pub extern "C" fn BumpTransactionEvent_htlcresolution(claim_id: crate::c_types::ThirtyTwoBytes, target_feerate_sat_per_1000_weight: u32, htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, tx_lock_time: u32) -> BumpTransactionEvent { + BumpTransactionEvent::HTLCResolution { + claim_id, + target_feerate_sat_per_1000_weight, + htlc_descriptors, + tx_lock_time, + } +} +/// Checks if two BumpTransactionEvents contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn BumpTransactionEvent_eq(a: &BumpTransactionEvent, b: &BumpTransactionEvent) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning::events::bump_transaction::Input as nativeInputImport; +pub(crate) type nativeInput = nativeInputImport; + +/// An input that must be included in a transaction when performing coin selection through +/// [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it +/// must have an empty [`TxIn::script_sig`] when spent. +#[must_use] +#[repr(C)] +pub struct Input { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Input { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Input, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Input_free(this_obj: Input) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Input_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInput) }; +} +#[allow(unused)] +impl Input { + pub(crate) fn get_native_ref(&self) -> &'static nativeInput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The unique identifier of the input. +#[no_mangle] +pub extern "C" fn Input_get_outpoint(this_ptr: &Input) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + crate::c_types::bitcoin_to_C_outpoint(inner_val) +} +/// The unique identifier of the input. +#[no_mangle] +pub extern "C" fn Input_set_outpoint(this_ptr: &mut Input, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val); +} +/// The UTXO being spent by the input. +#[no_mangle] +pub extern "C" fn Input_get_previous_utxo(this_ptr: &Input) -> crate::c_types::TxOut { + let mut inner_val = &mut this_ptr.get_native_mut_ref().previous_utxo; + crate::c_types::TxOut::from_rust(inner_val) +} +/// The UTXO being spent by the input. +#[no_mangle] +pub extern "C" fn Input_set_previous_utxo(this_ptr: &mut Input, mut val: crate::c_types::TxOut) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previous_utxo = val.into_rust(); +} +/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and +/// [`TxIn::witness`], each with their lengths included, required to satisfy the output's +/// script. +#[no_mangle] +pub extern "C" fn Input_get_satisfaction_weight(this_ptr: &Input) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight; + *inner_val +} +/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and +/// [`TxIn::witness`], each with their lengths included, required to satisfy the output's +/// script. +#[no_mangle] +pub extern "C" fn Input_set_satisfaction_weight(this_ptr: &mut Input, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val; +} +/// Constructs a new Input given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Input_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut previous_utxo_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Input { + Input { inner: ObjOps::heap_alloc(nativeInput { + outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg), + previous_utxo: previous_utxo_arg.into_rust(), + satisfaction_weight: satisfaction_weight_arg, + }), is_owned: true } +} +impl Clone for Input { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Input_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Input +pub extern "C" fn Input_clone(orig: &Input) -> Input { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the Input. +#[no_mangle] +pub extern "C" fn Input_hash(o: &Input) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two Inputs 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. +#[no_mangle] +pub extern "C" fn Input_eq(a: &Input, b: &Input) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::events::bump_transaction::Utxo as nativeUtxoImport; +pub(crate) type nativeUtxo = nativeUtxoImport; + +/// An unspent transaction output that is available to spend resulting from a successful +/// [`CoinSelection`] attempt. +#[must_use] +#[repr(C)] +pub struct Utxo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeUtxo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Utxo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Utxo_free(this_obj: Utxo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Utxo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUtxo) }; +} +#[allow(unused)] +impl Utxo { + pub(crate) fn get_native_ref(&self) -> &'static nativeUtxo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUtxo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeUtxo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The unique identifier of the output. +#[no_mangle] +pub extern "C" fn Utxo_get_outpoint(this_ptr: &Utxo) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + crate::c_types::bitcoin_to_C_outpoint(inner_val) +} +/// The unique identifier of the output. +#[no_mangle] +pub extern "C" fn Utxo_set_outpoint(this_ptr: &mut Utxo, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = crate::c_types::C_to_bitcoin_outpoint(val); +} +/// The output to spend. +#[no_mangle] +pub extern "C" fn Utxo_get_output(this_ptr: &Utxo) -> crate::c_types::TxOut { + let mut inner_val = &mut this_ptr.get_native_mut_ref().output; + crate::c_types::TxOut::from_rust(inner_val) +} +/// The output to spend. +#[no_mangle] +pub extern "C" fn Utxo_set_output(this_ptr: &mut Utxo, mut val: crate::c_types::TxOut) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); +} +/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each +/// with their lengths included, required to satisfy the output's script. The weight consumed by +/// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. +#[no_mangle] +pub extern "C" fn Utxo_get_satisfaction_weight(this_ptr: &Utxo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().satisfaction_weight; + *inner_val +} +/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each +/// with their lengths included, required to satisfy the output's script. The weight consumed by +/// the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. +#[no_mangle] +pub extern "C" fn Utxo_set_satisfaction_weight(this_ptr: &mut Utxo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.satisfaction_weight = val; +} +/// Constructs a new Utxo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Utxo_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut satisfaction_weight_arg: u64) -> Utxo { + Utxo { inner: ObjOps::heap_alloc(nativeUtxo { + outpoint: crate::c_types::C_to_bitcoin_outpoint(outpoint_arg), + output: output_arg.into_rust(), + satisfaction_weight: satisfaction_weight_arg, + }), is_owned: true } +} +impl Clone for Utxo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUtxo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Utxo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUtxo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Utxo +pub extern "C" fn Utxo_clone(orig: &Utxo) -> Utxo { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the Utxo. +#[no_mangle] +pub extern "C" fn Utxo_hash(o: &Utxo) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two Utxos 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. +#[no_mangle] +pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. +#[must_use] +#[no_mangle] +pub extern "C" fn Utxo_new_p2pkh(mut outpoint: crate::lightning::chain::transaction::OutPoint, mut value: u64, pubkey_hash: *const [u8; 20]) -> crate::lightning::events::bump_transaction::Utxo { + let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), value, &bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(unsafe { *pubkey_hash }.clone()))); + crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + + +use lightning::events::bump_transaction::CoinSelection as nativeCoinSelectionImport; +pub(crate) type nativeCoinSelection = nativeCoinSelectionImport; + +/// The result of a successful coin selection attempt for a transaction requiring additional UTXOs +/// to cover its fees. +#[must_use] +#[repr(C)] +pub struct CoinSelection { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeCoinSelection, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for CoinSelection { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CoinSelection_free(this_obj: CoinSelection) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CoinSelection_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCoinSelection) }; +} +#[allow(unused)] +impl CoinSelection { + pub(crate) fn get_native_ref(&self) -> &'static nativeCoinSelection { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCoinSelection { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeCoinSelection { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction +/// requiring additional fees. +#[no_mangle] +pub extern "C" fn CoinSelection_get_confirmed_utxos(this_ptr: &CoinSelection) -> crate::c_types::derived::CVec_UtxoZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmed_utxos; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::events::bump_transaction::Utxo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::events::bump_transaction::Utxo<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction +/// requiring additional fees. +#[no_mangle] +pub extern "C" fn CoinSelection_set_confirmed_utxos(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::CVec_UtxoZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmed_utxos = local_val; +} +/// An additional output tracking whether any change remained after coin selection. This output +/// should always have a value above dust for its given `script_pubkey`. It should not be +/// spent until the transaction it belongs to confirms to ensure mempool descendant limits are +/// not met. This implies no other party should be able to spend it except us. +#[no_mangle] +pub extern "C" fn CoinSelection_get_change_output(this_ptr: &CoinSelection) -> crate::c_types::derived::COption_TxOutZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().change_output; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxOutZ::None } else { crate::c_types::derived::COption_TxOutZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::TxOut::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// An additional output tracking whether any change remained after coin selection. This output +/// should always have a value above dust for its given `script_pubkey`. It should not be +/// spent until the transaction it belongs to confirms to ensure mempool descendant limits are +/// not met. This implies no other party should be able to spend it except us. +#[no_mangle] +pub extern "C" fn CoinSelection_set_change_output(this_ptr: &mut CoinSelection, mut val: crate::c_types::derived::COption_TxOutZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.change_output = local_val; +} +/// Constructs a new CoinSelection given each field +#[must_use] +#[no_mangle] +pub extern "C" fn CoinSelection_new(mut confirmed_utxos_arg: crate::c_types::derived::CVec_UtxoZ, mut change_output_arg: crate::c_types::derived::COption_TxOutZ) -> CoinSelection { + let mut local_confirmed_utxos_arg = Vec::new(); for mut item in confirmed_utxos_arg.into_rust().drain(..) { local_confirmed_utxos_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_change_output_arg = { /*change_output_arg*/ let change_output_arg_opt = change_output_arg; if change_output_arg_opt.is_none() { None } else { Some({ { { change_output_arg_opt.take() }.into_rust() }})} }; + CoinSelection { inner: ObjOps::heap_alloc(nativeCoinSelection { + confirmed_utxos: local_confirmed_utxos_arg, + change_output: local_change_output_arg, + }), is_owned: true } +} +impl Clone for CoinSelection { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCoinSelection>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CoinSelection_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCoinSelection)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CoinSelection +pub extern "C" fn CoinSelection_clone(orig: &CoinSelection) -> CoinSelection { + orig.clone() +} +/// An abstraction over a bitcoin wallet that can perform coin selection over a set of UTXOs and can +/// sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC, +/// which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`], +/// which can provide a default implementation of this trait when used with [`Wallet`]. +#[repr(C)] +pub struct CoinSelectionSource { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are + /// available to spend. Implementations are free to pick their coin selection algorithm of + /// choice, as long as the following requirements are met: + /// + /// 1. `must_spend` contains a set of [`Input`]s that must be included in the transaction + /// throughout coin selection, but must not be returned as part of the result. + /// 2. `must_pay_to` contains a set of [`TxOut`]s that must be included in the transaction + /// throughout coin selection. In some cases, like when funding an anchor transaction, this + /// set is empty. Implementations should ensure they handle this correctly on their end, + /// e.g., Bitcoin Core's `fundrawtransaction` RPC requires at least one output to be + /// provided, in which case a zero-value empty OP_RETURN output can be used instead. + /// 3. Enough inputs must be selected/contributed for the resulting transaction (including the + /// inputs and outputs noted above) to meet `target_feerate_sat_per_1000_weight`. + /// + /// Implementations must take note that [`Input::satisfaction_weight`] only tracks the weight of + /// the input's `script_sig` and `witness`. Some wallets, like Bitcoin Core's, may require + /// providing the full input weight. Failing to do so may lead to underestimating fee bumps and + /// delaying block inclusion. + /// + /// The `claim_id` must map to the set of external UTXOs assigned to the claim, such that they + /// can be re-used within new fee-bumped iterations of the original claiming transaction, + /// ensuring that claims don't double spend each other. If a specific `claim_id` has never had a + /// transaction associated with it, and all of the available UTXOs have already been assigned to + /// other claims, implementations must be willing to double spend their UTXOs. The choice of + /// which UTXOs to double spend is left to the implementation, but it must strive to keep the + /// set of other claims being double spent to a minimum. + pub select_confirmed_utxos: extern "C" fn (this_arg: *const c_void, claim_id: crate::c_types::ThirtyTwoBytes, must_spend: crate::c_types::derived::CVec_InputZ, must_pay_to: crate::c_types::derived::CVec_TxOutZ, target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ, + /// Signs and provides the full witness for all inputs within the transaction known to the + /// trait (i.e., any provided via [`CoinSelectionSource::select_confirmed_utxos`]). + pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for CoinSelectionSource {} +unsafe impl Sync for CoinSelectionSource {} +#[no_mangle] +pub(crate) extern "C" fn CoinSelectionSource_clone_fields(orig: &CoinSelectionSource) -> CoinSelectionSource { + CoinSelectionSource { + this_arg: orig.this_arg, + select_confirmed_utxos: Clone::clone(&orig.select_confirmed_utxos), + sign_tx: Clone::clone(&orig.sign_tx), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::bump_transaction::CoinSelectionSource as rustCoinSelectionSource; +impl rustCoinSelectionSource for CoinSelectionSource { + fn select_confirmed_utxos(&self, mut claim_id: lightning::chain::ClaimId, mut must_spend: Vec, mut must_pay_to: &[bitcoin::TxOut], mut target_feerate_sat_per_1000_weight: u32) -> Result { + let mut local_must_spend = Vec::new(); for mut item in must_spend.drain(..) { local_must_spend.push( { crate::lightning::events::bump_transaction::Input { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_must_pay_to_clone = Vec::new(); local_must_pay_to_clone.extend_from_slice(must_pay_to); let mut must_pay_to = local_must_pay_to_clone; let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.drain(..) { local_must_pay_to.push( { crate::c_types::TxOut::from_rust(&item) }); }; + let mut ret = (self.select_confirmed_utxos)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, local_must_spend.into(), local_must_pay_to.into(), target_feerate_sat_per_1000_weight); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result { + let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for CoinSelectionSource { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn CoinSelectionSource_free(this_ptr: CoinSelectionSource) { } +impl Drop for CoinSelectionSource { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to +/// provide a default implementation to [`CoinSelectionSource`]. +#[repr(C)] +pub struct WalletSource { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns all UTXOs, with at least 1 confirmation each, that are available to spend. + pub list_confirmed_utxos: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_UtxoZNoneZ, + /// Returns a script to use for change above dust resulting from a successful coin selection + /// attempt. + pub get_change_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_ScriptNoneZ, + /// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within + /// the transaction known to the wallet (i.e., any provided via + /// [`WalletSource::list_confirmed_utxos`]). + pub sign_tx: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for WalletSource {} +unsafe impl Sync for WalletSource {} +#[no_mangle] +pub(crate) extern "C" fn WalletSource_clone_fields(orig: &WalletSource) -> WalletSource { + WalletSource { + this_arg: orig.this_arg, + list_confirmed_utxos: Clone::clone(&orig.list_confirmed_utxos), + get_change_script: Clone::clone(&orig.get_change_script), + sign_tx: Clone::clone(&orig.sign_tx), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::bump_transaction::WalletSource as rustWalletSource; +impl rustWalletSource for WalletSource { + fn list_confirmed_utxos(&self) -> Result, ()> { + let mut ret = (self.list_confirmed_utxos)(self.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn get_change_script(&self) -> Result { + let mut ret = (self.get_change_script)(self.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::Script::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_tx(&self, mut tx: bitcoin::Transaction) -> Result { + let mut ret = (self.sign_tx)(self.this_arg, crate::c_types::Transaction::from_bitcoin(&tx)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for WalletSource { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn WalletSource_free(this_ptr: WalletSource) { } +impl Drop for WalletSource { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} + +use lightning::events::bump_transaction::Wallet as nativeWalletImport; +pub(crate) type nativeWallet = nativeWalletImport; + +/// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would +/// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double +/// spends may happen. +#[must_use] +#[repr(C)] +pub struct Wallet { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeWallet, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Wallet { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Wallet_free(this_obj: Wallet) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Wallet_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeWallet) }; +} +#[allow(unused)] +impl Wallet { + pub(crate) fn get_native_ref(&self) -> &'static nativeWallet { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWallet { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeWallet { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation +/// of [`CoinSelectionSource`]. +#[must_use] +#[no_mangle] +pub extern "C" fn Wallet_new(mut source: crate::lightning::events::bump_transaction::WalletSource, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::Wallet { + let mut ret = lightning::events::bump_transaction::Wallet::new(source, logger); + crate::lightning::events::bump_transaction::Wallet { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::events::bump_transaction::CoinSelectionSource { + fn from(obj: nativeWallet) -> Self { + let mut rust_obj = Wallet { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = Wallet_as_CoinSelectionSource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(Wallet_free_void); + ret + } +} +/// Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn Wallet_as_CoinSelectionSource(this_arg: &Wallet) -> crate::lightning::events::bump_transaction::CoinSelectionSource { + crate::lightning::events::bump_transaction::CoinSelectionSource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + select_confirmed_utxos: Wallet_CoinSelectionSource_select_confirmed_utxos, + sign_tx: Wallet_CoinSelectionSource_sign_tx, + } +} + +#[must_use] +extern "C" fn Wallet_CoinSelectionSource_select_confirmed_utxos(this_arg: *const c_void, mut claim_id: crate::c_types::ThirtyTwoBytes, mut must_spend: crate::c_types::derived::CVec_InputZ, mut must_pay_to: crate::c_types::derived::CVec_TxOutZ, mut target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ { + let mut local_must_spend = Vec::new(); for mut item in must_spend.into_rust().drain(..) { local_must_spend.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.into_rust().drain(..) { local_must_pay_to.push( { item.into_rust() }); }; + let mut ret = >::select_confirmed_utxos(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::lightning::chain::ClaimId(claim_id.data), local_must_spend, &local_must_pay_to[..], target_feerate_sat_per_1000_weight); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::CoinSelection { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn Wallet_CoinSelectionSource_sign_tx(this_arg: *const c_void, mut tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut ret = >::sign_tx(unsafe { &mut *(this_arg as *mut nativeWallet) }, tx.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::events::bump_transaction::BumpTransactionEventHandler as nativeBumpTransactionEventHandlerImport; +pub(crate) type nativeBumpTransactionEventHandler = nativeBumpTransactionEventHandlerImport; + +/// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a +/// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or +/// Replace-By-Fee (RBF). +/// +/// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction +#[must_use] +#[repr(C)] +pub struct BumpTransactionEventHandler { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBumpTransactionEventHandler, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for BumpTransactionEventHandler { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BumpTransactionEventHandler_free(this_obj: BumpTransactionEventHandler) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BumpTransactionEventHandler_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBumpTransactionEventHandler) }; +} +#[allow(unused)] +impl BumpTransactionEventHandler { + pub(crate) fn get_native_ref(&self) -> &'static nativeBumpTransactionEventHandler { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBumpTransactionEventHandler { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBumpTransactionEventHandler { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Returns a new instance capable of handling [`Event::BumpTransaction`] events. +/// +/// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction +#[must_use] +#[no_mangle] +pub extern "C" fn BumpTransactionEventHandler_new(mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut utxo_source: crate::lightning::events::bump_transaction::CoinSelectionSource, mut signer_provider: crate::lightning::sign::SignerProvider, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::events::bump_transaction::BumpTransactionEventHandler { + let mut ret = lightning::events::bump_transaction::BumpTransactionEventHandler::new(broadcaster, utxo_source, signer_provider, logger); + crate::lightning::events::bump_transaction::BumpTransactionEventHandler { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Handles all variants of [`BumpTransactionEvent`]. +#[no_mangle] +pub extern "C" fn BumpTransactionEventHandler_handle_event(this_arg: &crate::lightning::events::bump_transaction::BumpTransactionEventHandler, event: &crate::lightning::events::bump_transaction::BumpTransactionEvent) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_event(&event.to_native()) +} + diff --git a/lightning-c-bindings/src/lightning/events/mod.rs b/lightning-c-bindings/src/lightning/events/mod.rs new file mode 100644 index 0000000..cfef8ae --- /dev/null +++ b/lightning-c-bindings/src/lightning/events/mod.rs @@ -0,0 +1,4178 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Events are returned from various bits in the library which indicate some action must be taken +//! by the client. +//! +//! Because we don't have a built-in runtime, it's up to the client to call events at a time in the +//! future, as well as generate and broadcast funding transactions handle payment preimages and a +//! few other things. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod bump_transaction; +/// Some information provided on receipt of payment depends on whether the payment received is a +/// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PaymentPurpose { + /// Information for receiving a payment that we generated an invoice for. + InvoicePayment { + /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via + /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + /// [`ChannelManager::claim_funds`]. + /// + /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, + /// The \"payment secret\". This authenticates the sender to the recipient, preventing a + /// number of deanonymization attacks during the routing process. + /// It is provided here for your reference, however its accuracy is enforced directly by + /// [`ChannelManager`] using the values you previously provided to + /// [`ChannelManager::create_inbound_payment`] or + /// [`ChannelManager::create_inbound_payment_for_hash`]. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + payment_secret: crate::c_types::ThirtyTwoBytes, + }, + /// Because this is a spontaneous payment, the payer generated their own preimage rather than us + /// (the payee) providing a preimage. + SpontaneousPayment( + crate::c_types::ThirtyTwoBytes), +} +use lightning::events::PaymentPurpose as PaymentPurposeImport; +pub(crate) type nativePaymentPurpose = PaymentPurposeImport; + +impl PaymentPurpose { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePaymentPurpose { + match self { + PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + nativePaymentPurpose::InvoicePayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data), + } + }, + PaymentPurpose::SpontaneousPayment (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativePaymentPurpose::SpontaneousPayment ( + ::lightning::ln::PaymentPreimage(a_nonref.data), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePaymentPurpose { + match self { + PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + nativePaymentPurpose::InvoicePayment { + payment_preimage: local_payment_preimage, + payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data), + } + }, + PaymentPurpose::SpontaneousPayment (mut a, ) => { + nativePaymentPurpose::SpontaneousPayment ( + ::lightning::ln::PaymentPreimage(a.data), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self { + match native { + nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::derived::COption_PaymentPreimageZ::None } else { crate::c_types::derived::COption_PaymentPreimageZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.unwrap().0 } }) }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + PaymentPurpose::InvoicePayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, + } + }, + nativePaymentPurpose::SpontaneousPayment (ref a, ) => { + let mut a_nonref = Clone::clone(a); + PaymentPurpose::SpontaneousPayment ( + crate::c_types::ThirtyTwoBytes { data: a_nonref.0 }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePaymentPurpose) -> Self { + match native { + nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { + let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::derived::COption_PaymentPreimageZ::None } else { crate::c_types::derived::COption_PaymentPreimageZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage.unwrap().0 } }) }; + PaymentPurpose::InvoicePayment { + payment_preimage: local_payment_preimage, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, + } + }, + nativePaymentPurpose::SpontaneousPayment (mut a, ) => { + PaymentPurpose::SpontaneousPayment ( + crate::c_types::ThirtyTwoBytes { data: a.0 }, + ) + }, + } + } +} +/// Frees any resources used by the PaymentPurpose +#[no_mangle] +pub extern "C" fn PaymentPurpose_free(this_ptr: PaymentPurpose) { } +/// Creates a copy of the PaymentPurpose +#[no_mangle] +pub extern "C" fn PaymentPurpose_clone(orig: &PaymentPurpose) -> PaymentPurpose { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new InvoicePayment-variant PaymentPurpose +pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { + PaymentPurpose::InvoicePayment { + payment_preimage, + payment_secret, + } +} +#[no_mangle] +/// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose +pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { + PaymentPurpose::SpontaneousPayment(a, ) +} +/// Checks if two PaymentPurposes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read +pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write +pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may +/// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. +/// +/// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate +/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PathFailure { + /// We failed to initially send the payment and no HTLC was committed to. Contains the relevant + /// error. + InitialSend { + /// The error surfaced from initial send. + err: crate::lightning::util::errors::APIError, + }, + /// A hop on the path failed to forward our payment. + OnPath { + /// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing + /// decisions can take into account the update. + /// + /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate + /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + network_update: crate::c_types::derived::COption_NetworkUpdateZ, + }, +} +use lightning::events::PathFailure as PathFailureImport; +pub(crate) type nativePathFailure = PathFailureImport; + +impl PathFailure { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePathFailure { + match self { + PathFailure::InitialSend {ref err, } => { + let mut err_nonref = Clone::clone(err); + nativePathFailure::InitialSend { + err: err_nonref.into_native(), + } + }, + PathFailure::OnPath {ref network_update, } => { + let mut network_update_nonref = Clone::clone(network_update); + let mut local_network_update_nonref = { /*network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; if network_update_nonref_opt.is_none() { None } else { Some({ { { network_update_nonref_opt.take() }.into_native() }})} }; + nativePathFailure::OnPath { + network_update: local_network_update_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePathFailure { + match self { + PathFailure::InitialSend {mut err, } => { + nativePathFailure::InitialSend { + err: err.into_native(), + } + }, + PathFailure::OnPath {mut network_update, } => { + let mut local_network_update = { /*network_update*/ let network_update_opt = network_update; if network_update_opt.is_none() { None } else { Some({ { { network_update_opt.take() }.into_native() }})} }; + nativePathFailure::OnPath { + network_update: local_network_update, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativePathFailure) -> Self { + match native { + nativePathFailure::InitialSend {ref err, } => { + let mut err_nonref = Clone::clone(err); + PathFailure::InitialSend { + err: crate::lightning::util::errors::APIError::native_into(err_nonref), + } + }, + nativePathFailure::OnPath {ref network_update, } => { + let mut network_update_nonref = Clone::clone(network_update); + let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) }; + PathFailure::OnPath { + network_update: local_network_update_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePathFailure) -> Self { + match native { + nativePathFailure::InitialSend {mut err, } => { + PathFailure::InitialSend { + err: crate::lightning::util::errors::APIError::native_into(err), + } + }, + nativePathFailure::OnPath {mut network_update, } => { + let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update.unwrap()) }) }; + PathFailure::OnPath { + network_update: local_network_update, + } + }, + } + } +} +/// Frees any resources used by the PathFailure +#[no_mangle] +pub extern "C" fn PathFailure_free(this_ptr: PathFailure) { } +/// Creates a copy of the PathFailure +#[no_mangle] +pub extern "C" fn PathFailure_clone(orig: &PathFailure) -> PathFailure { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new InitialSend-variant PathFailure +pub extern "C" fn PathFailure_initial_send(err: crate::lightning::util::errors::APIError) -> PathFailure { + PathFailure::InitialSend { + err, + } +} +#[no_mangle] +/// Utility method to constructs a new OnPath-variant PathFailure +pub extern "C" fn PathFailure_on_path(network_update: crate::c_types::derived::COption_NetworkUpdateZ) -> PathFailure { + PathFailure::OnPath { + network_update, + } +} +/// Checks if two PathFailures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the PathFailure object into a byte array which can be read by PathFailure_read +pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a PathFailure from a byte array, created by PathFailure_write +pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// The reason the channel was closed. See individual variants for more details. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum ClosureReason { + /// Closure generated from receiving a peer error message. + /// + /// Our counterparty may have broadcasted their latest commitment state, and we have + /// as well. + CounterpartyForceClosed { + /// The error which the peer sent us. + /// + /// Be careful about printing the peer_msg, a well-crafted message could exploit + /// a security vulnerability in the terminal emulator or the logging subsystem. + /// To be safe, use `Display` on `UntrustedString` + /// + /// [`UntrustedString`]: crate::util::string::UntrustedString + peer_msg: crate::lightning::util::string::UntrustedString, + }, + /// Closure generated from [`ChannelManager::force_close_channel`], called by the user. + /// + /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. + HolderForceClosed, + /// The channel was closed after negotiating a cooperative close and we've now broadcasted + /// the cooperative close transaction. Note the shutdown may have been initiated by us. + CooperativeClosure, + /// A commitment transaction was confirmed on chain, closing the channel. Most likely this + /// commitment transaction came from our counterparty, but it may also have come from + /// a copy of our own `ChannelMonitor`. + CommitmentTxConfirmed, + /// The funding transaction failed to confirm in a timely manner on an inbound channel. + FundingTimedOut, + /// Closure generated from processing an event, likely a HTLC forward/relay/reception. + ProcessingError { + /// A developer-readable error message which we generated. + err: crate::c_types::Str, + }, + /// The peer disconnected prior to funding completing. In this case the spec mandates that we + /// forget the channel entirely - we can attempt again if the peer reconnects. + /// + /// This includes cases where we restarted prior to funding completion, including prior to the + /// initial [`ChannelMonitor`] persistence completing. + /// + /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + /// peer because of mutual incompatibility between us and our channel counterparty. + /// + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + DisconnectedPeer, + /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than + /// the [`ChannelManager`] deserialized. + /// + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + OutdatedChannelManager, + /// The counterparty requested a cooperative close of a channel that had not been funded yet. + /// The channel has been immediately closed. + CounterpartyCoopClosedUnfundedChannel, +} +use lightning::events::ClosureReason as ClosureReasonImport; +pub(crate) type nativeClosureReason = ClosureReasonImport; + +impl ClosureReason { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeClosureReason { + match self { + ClosureReason::CounterpartyForceClosed {ref peer_msg, } => { + let mut peer_msg_nonref = Clone::clone(peer_msg); + nativeClosureReason::CounterpartyForceClosed { + peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, + } + }, + ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, + ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, + ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, + ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, + ClosureReason::ProcessingError {ref err, } => { + let mut err_nonref = Clone::clone(err); + nativeClosureReason::ProcessingError { + err: err_nonref.into_string(), + } + }, + ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, + ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, + ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeClosureReason { + match self { + ClosureReason::CounterpartyForceClosed {mut peer_msg, } => { + nativeClosureReason::CounterpartyForceClosed { + peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, + } + }, + ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, + ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, + ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, + ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, + ClosureReason::ProcessingError {mut err, } => { + nativeClosureReason::ProcessingError { + err: err.into_string(), + } + }, + ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, + ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, + ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeClosureReason) -> Self { + match native { + nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => { + let mut peer_msg_nonref = Clone::clone(peer_msg); + ClosureReason::CounterpartyForceClosed { + peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, + } + }, + nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, + nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, + nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, + nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, + nativeClosureReason::ProcessingError {ref err, } => { + let mut err_nonref = Clone::clone(err); + ClosureReason::ProcessingError { + err: err_nonref.into(), + } + }, + nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, + nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, + nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeClosureReason) -> Self { + match native { + nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => { + ClosureReason::CounterpartyForceClosed { + peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, + } + }, + nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, + nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, + nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, + nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, + nativeClosureReason::ProcessingError {mut err, } => { + ClosureReason::ProcessingError { + err: err.into(), + } + }, + nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, + nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, + nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, + } + } +} +/// Frees any resources used by the ClosureReason +#[no_mangle] +pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { } +/// Creates a copy of the ClosureReason +#[no_mangle] +pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason +pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason { + ClosureReason::CounterpartyForceClosed { + peer_msg, + } +} +#[no_mangle] +/// Utility method to constructs a new HolderForceClosed-variant ClosureReason +pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason { + ClosureReason::HolderForceClosed} +#[no_mangle] +/// Utility method to constructs a new CooperativeClosure-variant ClosureReason +pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason { + ClosureReason::CooperativeClosure} +#[no_mangle] +/// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason +pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason { + ClosureReason::CommitmentTxConfirmed} +#[no_mangle] +/// Utility method to constructs a new FundingTimedOut-variant ClosureReason +pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason { + ClosureReason::FundingTimedOut} +#[no_mangle] +/// Utility method to constructs a new ProcessingError-variant ClosureReason +pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason { + ClosureReason::ProcessingError { + err, + } +} +#[no_mangle] +/// Utility method to constructs a new DisconnectedPeer-variant ClosureReason +pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason { + ClosureReason::DisconnectedPeer} +#[no_mangle] +/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason +pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason { + ClosureReason::OutdatedChannelManager} +#[no_mangle] +/// Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason +pub extern "C" fn ClosureReason_counterparty_coop_closed_unfunded_channel() -> ClosureReason { + ClosureReason::CounterpartyCoopClosedUnfundedChannel} +/// Checks if two ClosureReasons contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read +pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a ClosureReason from a byte array, created by ClosureReason_write +pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum HTLCDestination { + /// We tried forwarding to a channel but failed to do so. An example of such an instance is when + /// there is insufficient capacity in our outbound channel. + NextHopChannel { + /// The `node_id` of the next node. For backwards compatibility, this field is + /// marked as optional, versions prior to 0.0.110 may not always be able to provide + /// counterparty node information. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + node_id: crate::c_types::PublicKey, + /// The outgoing `channel_id` between us and the next node. + channel_id: crate::c_types::ThirtyTwoBytes, + }, + /// Scenario where we are unsure of the next node to forward the HTLC to. + UnknownNextHop { + /// Short channel id we are requesting to forward an HTLC to. + requested_forward_scid: u64, + }, + /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate + /// intercept HTLC. + InvalidForward { + /// Short channel id we are requesting to forward an HTLC to. + requested_forward_scid: u64, + }, + /// Failure scenario where an HTLC may have been forwarded to be intended for us, + /// but is invalid for some reason, so we reject it. + /// + /// Some of the reasons may include: + /// * HTLC Timeouts + /// * Excess HTLCs for a payment that we have already fully received, over-paying for the + /// payment, + /// * The counterparty node modified the HTLC in transit, + /// * A probing attack where an intermediary node is trying to detect if we are the ultimate + /// recipient for a payment. + FailedPayment { + /// The payment hash of the payment we attempted to process. + payment_hash: crate::c_types::ThirtyTwoBytes, + }, +} +use lightning::events::HTLCDestination as HTLCDestinationImport; +pub(crate) type nativeHTLCDestination = HTLCDestinationImport; + +impl HTLCDestination { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeHTLCDestination { + match self { + HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) }; + let mut channel_id_nonref = Clone::clone(channel_id); + nativeHTLCDestination::NextHopChannel { + node_id: local_node_id_nonref, + channel_id: channel_id_nonref.data, + } + }, + HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { + let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); + nativeHTLCDestination::UnknownNextHop { + requested_forward_scid: requested_forward_scid_nonref, + } + }, + HTLCDestination::InvalidForward {ref requested_forward_scid, } => { + let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); + nativeHTLCDestination::InvalidForward { + requested_forward_scid: requested_forward_scid_nonref, + } + }, + HTLCDestination::FailedPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + nativeHTLCDestination::FailedPayment { + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeHTLCDestination { + match self { + HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { + let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) }; + nativeHTLCDestination::NextHopChannel { + node_id: local_node_id, + channel_id: channel_id.data, + } + }, + HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { + nativeHTLCDestination::UnknownNextHop { + requested_forward_scid: requested_forward_scid, + } + }, + HTLCDestination::InvalidForward {mut requested_forward_scid, } => { + nativeHTLCDestination::InvalidForward { + requested_forward_scid: requested_forward_scid, + } + }, + HTLCDestination::FailedPayment {mut payment_hash, } => { + nativeHTLCDestination::FailedPayment { + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self { + match native { + nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut local_node_id_nonref = if node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id_nonref.unwrap())) } }; + let mut channel_id_nonref = Clone::clone(channel_id); + HTLCDestination::NextHopChannel { + node_id: local_node_id_nonref, + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + } + }, + nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { + let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); + HTLCDestination::UnknownNextHop { + requested_forward_scid: requested_forward_scid_nonref, + } + }, + nativeHTLCDestination::InvalidForward {ref requested_forward_scid, } => { + let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); + HTLCDestination::InvalidForward { + requested_forward_scid: requested_forward_scid_nonref, + } + }, + nativeHTLCDestination::FailedPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + HTLCDestination::FailedPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeHTLCDestination) -> Self { + match native { + nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { + let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } }; + HTLCDestination::NextHopChannel { + node_id: local_node_id, + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + } + }, + nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { + HTLCDestination::UnknownNextHop { + requested_forward_scid: requested_forward_scid, + } + }, + nativeHTLCDestination::InvalidForward {mut requested_forward_scid, } => { + HTLCDestination::InvalidForward { + requested_forward_scid: requested_forward_scid, + } + }, + nativeHTLCDestination::FailedPayment {mut payment_hash, } => { + HTLCDestination::FailedPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + } + }, + } + } +} +/// Frees any resources used by the HTLCDestination +#[no_mangle] +pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { } +/// Creates a copy of the HTLCDestination +#[no_mangle] +pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new NextHopChannel-variant HTLCDestination +pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { + HTLCDestination::NextHopChannel { + node_id, + channel_id, + } +} +#[no_mangle] +/// Utility method to constructs a new UnknownNextHop-variant HTLCDestination +pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination { + HTLCDestination::UnknownNextHop { + requested_forward_scid, + } +} +#[no_mangle] +/// Utility method to constructs a new InvalidForward-variant HTLCDestination +pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) -> HTLCDestination { + HTLCDestination::InvalidForward { + requested_forward_scid, + } +} +#[no_mangle] +/// Utility method to constructs a new FailedPayment-variant HTLCDestination +pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { + HTLCDestination::FailedPayment { + payment_hash, + } +} +/// Checks if two HTLCDestinations contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read +pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a HTLCDestination from a byte array, created by HTLCDestination_write +pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// The reason the payment failed. Used in [`Event::PaymentFailed`]. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PaymentFailureReason { + /// The intended recipient rejected our payment. + RecipientRejected, + /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. + /// + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + UserAbandoned, + /// We exhausted all of our retry attempts while trying to send the payment, or we + /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry + /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will + /// have come before this. + /// + /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout + RetriesExhausted, + /// The payment expired while retrying, based on the provided + /// [`PaymentParameters::expiry_time`]. + /// + /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + PaymentExpired, + /// We failed to find a route while retrying the payment. + RouteNotFound, + /// This error should generally never happen. This likely means that there is a problem with + /// your router. + UnexpectedError, +} +use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; +pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; + +impl PaymentFailureReason { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePaymentFailureReason { + match self { + PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, + PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, + PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, + PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, + PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, + PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePaymentFailureReason { + match self { + PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, + PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, + PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, + PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, + PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, + PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self { + match native { + nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, + nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, + nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, + nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, + nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, + nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self { + match native { + nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, + nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, + nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, + nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, + nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, + nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + } + } +} +/// Creates a copy of the PaymentFailureReason +#[no_mangle] +pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason { + PaymentFailureReason::RecipientRejected} +#[no_mangle] +/// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason { + PaymentFailureReason::UserAbandoned} +#[no_mangle] +/// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason { + PaymentFailureReason::RetriesExhausted} +#[no_mangle] +/// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason { + PaymentFailureReason::PaymentExpired} +#[no_mangle] +/// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason { + PaymentFailureReason::RouteNotFound} +#[no_mangle] +/// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { + PaymentFailureReason::UnexpectedError} +/// Checks if two PaymentFailureReasons contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read +pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write +pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// An Event which you should probably take some action in response to. +/// +/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use +/// them directly as they don't round-trip exactly (for example FundingGenerationReady is never +/// written as it makes no sense to respond to it after reconnecting to peers). +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Event { + /// Used to indicate that the client should generate a funding transaction with the given + /// parameters and then call [`ChannelManager::funding_transaction_generated`]. + /// Generated in [`ChannelManager`] message handling. + /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your + /// counterparty can steal your funds! + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + FundingGenerationReady { + /// The random channel_id we picked which you'll need to pass into + /// [`ChannelManager::funding_transaction_generated`]. + /// + /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The counterparty's node_id, which you'll need to pass back into + /// [`ChannelManager::funding_transaction_generated`]. + /// + /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + counterparty_node_id: crate::c_types::PublicKey, + /// The value, in satoshis, that the output should have. + channel_value_satoshis: u64, + /// The script which should be used in the transaction output. + output_script: crate::c_types::derived::CVec_u8Z, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a + /// random value for an inbound channel. This may be zero for objects serialized with LDK + /// versions prior to 0.0.113. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + user_channel_id: crate::c_types::U128, + }, + /// Indicates that we've been offered a payment and it needs to be claimed via calling + /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. + /// + /// Note that if the preimage is not known, you should call + /// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] + /// to free up resources for this HTLC and avoid network congestion. + /// If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], + /// or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be + /// automatically failed. + /// + /// # Note + /// LDK will not stop an inbound payment from being paid multiple times, so multiple + /// `PaymentClaimable` events may be generated for the same payment. In such a case it is + /// polite (and required in the lightning specification) to fail the payment the second time + /// and give the sender their money back rather than accepting double payment. + /// + /// # Note + /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards + /// [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason + PaymentClaimable { + /// The node that will receive the payment after it has been claimed. + /// This is useful to identify payments received via [phantom nodes]. + /// This field will always be filled in when the event was generated by LDK versions + /// 0.0.113 and above. + /// + /// [phantom nodes]: crate::sign::PhantomKeysManager + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + receiver_node_id: crate::c_types::PublicKey, + /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will + /// not stop you from registering duplicate payment hashes for inbound payments. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The fields in the onion which were received with each HTLC. Only fields which were + /// identical in each HTLC involved in the payment will be included here. + /// + /// Payments received on LDK versions prior to 0.0.115 will have this field unset. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, + /// The value, in thousandths of a satoshi, that this payment is claimable for. May be greater + /// than the invoice amount. + /// + /// May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set + /// and the previous hop took an extra fee. + /// + /// # Note + /// If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this + /// field, you may lose money! + /// + /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + amount_msat: u64, + /// The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee + /// taken by our channel counterparty. + /// + /// Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set. + /// + /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + counterparty_skimmed_fee_msat: u64, + /// Information for claiming this received payment, based on whether the purpose of the + /// payment is to pay an invoice or to send a spontaneous payment. + purpose: crate::lightning::events::PaymentPurpose, + /// The `channel_id` indicating over which channel we received the payment. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + via_channel_id: crate::c_types::ThirtyTwoBytes, + /// The `user_channel_id` indicating over which channel we received the payment. + via_user_channel_id: crate::c_types::derived::COption_u128Z, + /// The block height at which this payment will be failed back and will no longer be + /// eligible for claiming. + /// + /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to + /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + claim_deadline: crate::c_types::derived::COption_u32Z, + }, + /// Indicates a payment has been claimed and we've received money! + /// + /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response + /// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a + /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding + /// [`Event::PaymentClaimable`] event. + /// + /// # Note + /// LDK will not stop an inbound payment from being paid multiple times, so multiple + /// `PaymentClaimable` events may be generated for the same payment. If you then call + /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get + /// multiple `PaymentClaimed` events. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + PaymentClaimed { + /// The node that received the payment. + /// This is useful to identify payments which were received via [phantom nodes]. + /// This field will always be filled in when the event was generated by LDK versions + /// 0.0.113 and above. + /// + /// [phantom nodes]: crate::sign::PhantomKeysManager + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + receiver_node_id: crate::c_types::PublicKey, + /// The payment hash of the claimed payment. Note that LDK will not stop you from + /// registering duplicate payment hashes for inbound payments. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The value, in thousandths of a satoshi, that this payment is for. May be greater than the + /// invoice amount. + amount_msat: u64, + /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a + /// spontaneous payment. + purpose: crate::lightning::events::PaymentPurpose, + }, + /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target + /// and we got back the payment preimage for it). + /// + /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` + /// event. In this situation, you SHOULD treat this payment as having succeeded. + PaymentSent { + /// The `payment_id` passed to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_id: crate::c_types::derived::COption_PaymentIdZ, + /// 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 + /// store it somehow! + payment_preimage: crate::c_types::ThirtyTwoBytes, + /// The hash that was given to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_hash: crate::c_types::ThirtyTwoBytes, + /// 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 + fee_paid_msat: crate::c_types::derived::COption_u64Z, + }, + /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events + /// provide failure information for each path attempt in the payment, including retries. + /// + /// This event is provided once there are no further pending HTLCs for the payment and the + /// payment is no longer retryable, due either to the [`Retry`] provided or + /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment. + /// + /// [`Retry`]: crate::ln::channelmanager::Retry + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + PaymentFailed { + /// The `payment_id` passed to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_id: crate::c_types::ThirtyTwoBytes, + /// The hash that was given to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The reason the payment failed. This is only `None` for events generated or serialized + /// by versions prior to 0.0.115. + reason: crate::c_types::derived::COption_PaymentFailureReasonZ, + }, + /// Indicates that a path for an outbound payment was successful. + /// + /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See + /// [`Event::PaymentSent`] for obtaining the payment preimage. + PaymentPathSuccessful { + /// The `payment_id` passed to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_id: crate::c_types::ThirtyTwoBytes, + /// The hash that was given to [`ChannelManager::send_payment`]. + /// + /// This will be `Some` for all payments which completed on LDK 0.0.104 or later. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_hash: crate::c_types::derived::COption_PaymentHashZ, + /// The payment path that was successful. + /// + /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain. + path: crate::lightning::routing::router::Path, + }, + /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to + /// handle the HTLC. + /// + /// Note that this does *not* indicate that all paths for an MPP payment have failed, see + /// [`Event::PaymentFailed`]. + /// + /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have + /// been exhausted. + /// + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + PaymentPathFailed { + /// The `payment_id` passed to [`ChannelManager::send_payment`]. + /// + /// This will be `Some` for all payment paths which failed on LDK 0.0.103 or later. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + payment_id: crate::c_types::derived::COption_PaymentIdZ, + /// The hash that was given to [`ChannelManager::send_payment`]. + /// + /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + payment_hash: crate::c_types::ThirtyTwoBytes, + /// Indicates the payment was rejected for some reason by the recipient. This implies that + /// the payment has failed, not just the route in question. If this is not set, the payment may + /// be retried via a different route. + payment_failed_permanently: bool, + /// Extra error details based on the failure type. May contain an update that needs to be + /// applied to the [`NetworkGraph`]. + /// + /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + failure: crate::lightning::events::PathFailure, + /// The payment path that failed. + path: crate::lightning::routing::router::Path, + /// The channel responsible for the failed payment path. + /// + /// Note that for route hints or for the first hop in a path this may be an SCID alias and + /// may not refer to a channel in the public network graph. These aliases may also collide + /// with channels in the public network graph. + /// + /// If this is `Some`, then the corresponding channel should be avoided when the payment is + /// retried. May be `None` for older [`Event`] serializations. + short_channel_id: crate::c_types::derived::COption_u64Z, + }, + /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. + ProbeSuccessful { + /// The id returned by [`ChannelManager::send_probe`]. + /// + /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + payment_id: crate::c_types::ThirtyTwoBytes, + /// The hash generated by [`ChannelManager::send_probe`]. + /// + /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The payment path that was successful. + path: crate::lightning::routing::router::Path, + }, + /// Indicates that a probe payment we sent failed at an intermediary node on the path. + ProbeFailed { + /// The id returned by [`ChannelManager::send_probe`]. + /// + /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + payment_id: crate::c_types::ThirtyTwoBytes, + /// The hash generated by [`ChannelManager::send_probe`]. + /// + /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The payment path that failed. + path: crate::lightning::routing::router::Path, + /// The channel responsible for the failed probe. + /// + /// Note that for route hints or for the first hop in a path this may be an SCID alias and + /// may not refer to a channel in the public network graph. These aliases may also collide + /// with channels in the public network graph. + short_channel_id: crate::c_types::derived::COption_u64Z, + }, + /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at + /// a time in the future. + /// + /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + PendingHTLCsForwardable { + /// The minimum amount of time that should be waited prior to calling + /// process_pending_htlc_forwards. To increase the effort required to correlate payments, + /// you should wait a random amount of time in roughly the range (now + time_forwardable, + /// now + 5*time_forwardable). + time_forwardable: u64, + }, + /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if + /// you've encoded an intercept scid in the receiver's invoice route hints using + /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. + /// + /// [`ChannelManager::forward_intercepted_htlc`] or + /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See + /// their docs for more information. + /// + /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs + /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc + HTLCIntercepted { + /// An id to help LDK identify which HTLC is being forwarded or failed. + intercept_id: crate::c_types::ThirtyTwoBytes, + /// The fake scid that was programmed as the next hop's scid, generated using + /// [`ChannelManager::get_intercept_scid`]. + /// + /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + requested_next_hop_scid: u64, + /// The payment hash used for this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// How many msats were received on the inbound edge of this HTLC. + inbound_amount_msat: u64, + /// How many msats the payer intended to route to the next node. Depending on the reason you are + /// intercepting this payment, you might take a fee by forwarding less than this amount. + /// Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116. + /// + /// Note that LDK will NOT check that expected fees were factored into this value. You MUST + /// check that whatever fee you want has been included here or subtract it as required. Further, + /// LDK will not stop you from forwarding more than you received. + expected_outbound_amount_msat: u64, + }, + /// Used to indicate that an output which you should know how to spend was confirmed on chain + /// and is now spendable. + /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + /// counterparty spending them due to some kind of timeout. Thus, you need to store them + /// somewhere and spend them when you create on-chain transactions. + SpendableOutputs { + /// The outputs which you should store as spendable by you. + outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, + }, + /// This event is generated when a payment has been successfully forwarded through us and a + /// forwarding fee earned. + PaymentForwarded { + /// The incoming channel between the previous node and us. This is only `None` for events + /// generated or serialized by versions prior to 0.0.107. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + prev_channel_id: crate::c_types::ThirtyTwoBytes, + /// The outgoing channel between the next node and us. This is only `None` for events + /// generated or serialized by versions prior to 0.0.107. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + next_channel_id: crate::c_types::ThirtyTwoBytes, + /// The fee, in milli-satoshis, which was earned as a result of the payment. + /// + /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC + /// was pending, the amount the next hop claimed will have been rounded down to the nearest + /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still + /// claimed the full value in millisatoshis from the source. In this case, + /// `claim_from_onchain_tx` will be set. + /// + /// If the channel which sent us the payment has been force-closed, we will claim the funds + /// via an on-chain transaction. In that case we do not yet know the on-chain transaction + /// fees which we will spend and will instead set this to `None`. It is possible duplicate + /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + /// `None`. + fee_earned_msat: crate::c_types::derived::COption_u64Z, + /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain + /// transaction. + claim_from_onchain_tx: bool, + /// The final amount forwarded, in milli-satoshis, after the fee is deducted. + /// + /// The caveat described above the `fee_earned_msat` field applies here as well. + outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z, + }, + /// Used to indicate that a channel with the given `channel_id` is being opened and pending + /// confirmation on-chain. + /// + /// This event is emitted when the funding transaction has been signed and is broadcast to the + /// network. For 0conf channels it will be immediately followed by the corresponding + /// [`Event::ChannelReady`] event. + ChannelPending { + /// The `channel_id` of the channel that is pending confirmation. + channel_id: crate::c_types::ThirtyTwoBytes, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + /// `user_channel_id` will be randomized for an inbound channel. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + user_channel_id: crate::c_types::U128, + /// The `temporary_channel_id` this channel used to be known by during channel establishment. + /// + /// Will be `None` for channels created prior to LDK version 0.0.115. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The `node_id` of the channel counterparty. + counterparty_node_id: crate::c_types::PublicKey, + /// The outpoint of the channel's funding transaction. + funding_txo: crate::lightning::chain::transaction::OutPoint, + }, + /// Used to indicate that a channel with the given `channel_id` is ready to + /// be used. This event is emitted either when the funding transaction has been confirmed + /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel + /// establishment. + ChannelReady { + /// The `channel_id` of the channel that is ready. + channel_id: crate::c_types::ThirtyTwoBytes, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + /// `user_channel_id` will be randomized for an inbound channel. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + user_channel_id: crate::c_types::U128, + /// The `node_id` of the channel counterparty. + counterparty_node_id: crate::c_types::PublicKey, + /// The features that this channel will operate with. + channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + }, + /// Used to indicate that a previously opened channel with the given `channel_id` is in the + /// process of closure. + ChannelClosed { + /// The `channel_id` of the channel which has been closed. Note that on-chain transactions + /// resolving the channel are likely still awaiting confirmation. + channel_id: crate::c_types::ThirtyTwoBytes, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + /// `user_channel_id` will be randomized for inbound channels. + /// This may be zero for inbound channels serialized prior to 0.0.113 and will always be + /// zero for objects serialized with LDK versions prior to 0.0.102. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + user_channel_id: crate::c_types::U128, + /// The reason the channel was closed. + reason: crate::lightning::events::ClosureReason, + }, + /// Used to indicate to the user that they can abandon the funding transaction and recycle the + /// inputs for another purpose. + DiscardFunding { + /// The channel_id of the channel which has been closed. + channel_id: crate::c_types::ThirtyTwoBytes, + /// The full transaction received from the user + transaction: crate::c_types::Transaction, + }, + /// Indicates a request to open a new channel by a peer. + /// + /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the + /// request, call [`ChannelManager::force_close_without_broadcasting_txn`]. + /// + /// The event is only triggered when a new open channel request is received and the + /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. + /// + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + OpenChannelRequest { + /// The temporary channel ID of the channel requested to be opened. + /// + /// When responding to the request, the `temporary_channel_id` should be passed + /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, + /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. + /// + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The node_id of the counterparty requesting to open the channel. + /// + /// When responding to the request, the `counterparty_node_id` should be passed + /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to + /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the + /// request. + /// + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + counterparty_node_id: crate::c_types::PublicKey, + /// The channel value of the requested channel. + funding_satoshis: u64, + /// Our starting balance in the channel if the request is accepted, in milli-satoshi. + push_msat: u64, + /// The features that this channel will operate with. If you reject the channel, a + /// well-behaved counterparty may automatically re-attempt the channel with a new set of + /// feature flags. + /// + /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, + /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + /// 0.0.106. + /// + /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, + /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + /// 0.0.107. Channels setting this type also need to get manually accepted via + /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], + /// or will be rejected otherwise. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + }, + /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to + /// forward it. + /// + /// Some scenarios where this event may be sent include: + /// * Insufficient capacity in the outbound channel + /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes + /// * When an unknown SCID is requested for forwarding a payment. + /// * Expected MPP amount has already been reached + /// * The HTLC has timed out + /// + /// This event, however, does not get generated if an HTLC fails to meet the forwarding + /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + HTLCHandlingFailed { + /// The channel over which the HTLC was received. + prev_channel_id: crate::c_types::ThirtyTwoBytes, + /// Destination of the HTLC that failed to be processed. + failed_next_destination: crate::lightning::events::HTLCDestination, + }, + /// Indicates that a transaction originating from LDK needs to have its fee bumped. This event + /// requires confirmed external funds to be readily available to spend. + /// + /// LDK does not currently generate this event unless the + /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. + /// It is limited to the scope of channels with anchor outputs. + /// + /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx + BumpTransaction( + crate::lightning::events::bump_transaction::BumpTransactionEvent), +} +use lightning::events::Event as EventImport; +pub(crate) type nativeEvent = EventImport; + +impl Event { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeEvent { + match self { + Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { + let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); + let mut output_script_nonref = Clone::clone(output_script); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + nativeEvent::FundingGenerationReady { + temporary_channel_id: temporary_channel_id_nonref.data, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + channel_value_satoshis: channel_value_satoshis_nonref, + output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()), + user_channel_id: user_channel_id_nonref.into(), + } + }, + Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { + let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); + let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) }; + let mut amount_msat_nonref = Clone::clone(amount_msat); + let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat); + let mut purpose_nonref = Clone::clone(purpose); + let mut via_channel_id_nonref = Clone::clone(via_channel_id); + let mut local_via_channel_id_nonref = if via_channel_id_nonref.data == [0; 32] { None } else { Some( { via_channel_id_nonref.data }) }; + let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); + let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} }; + let mut claim_deadline_nonref = Clone::clone(claim_deadline); + let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None }; + nativeEvent::PaymentClaimable { + receiver_node_id: local_receiver_node_id_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + onion_fields: local_onion_fields_nonref, + amount_msat: amount_msat_nonref, + counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref, + purpose: purpose_nonref.into_native(), + via_channel_id: local_via_channel_id_nonref, + via_user_channel_id: local_via_user_channel_id_nonref, + claim_deadline: local_claim_deadline_nonref, + } + }, + Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { + let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); + let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut amount_msat_nonref = Clone::clone(amount_msat); + let mut purpose_nonref = Clone::clone(purpose); + nativeEvent::PaymentClaimed { + receiver_node_id: local_receiver_node_id_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + amount_msat: amount_msat_nonref, + purpose: purpose_nonref.into_native(), + } + }, + Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut local_payment_id_nonref = { /*payment_id_nonref*/ let payment_id_nonref_opt = payment_id_nonref; if payment_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_nonref_opt.take() }.data) }})} }; + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); + let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None }; + nativeEvent::PaymentSent { + payment_id: local_payment_id_nonref, + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + fee_paid_msat: local_fee_paid_msat_nonref, + } + }, + Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut reason_nonref = Clone::clone(reason); + let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} }; + nativeEvent::PaymentFailed { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + reason: local_reason_nonref, + } + }, + Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; + let mut path_nonref = Clone::clone(path); + nativeEvent::PaymentPathSuccessful { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + payment_hash: local_payment_hash_nonref, + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, + } + }, + Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut local_payment_id_nonref = { /*payment_id_nonref*/ let payment_id_nonref_opt = payment_id_nonref; if payment_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_nonref_opt.take() }.data) }})} }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); + let mut failure_nonref = Clone::clone(failure); + let mut path_nonref = Clone::clone(path); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; + nativeEvent::PaymentPathFailed { + payment_id: local_payment_id_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_failed_permanently: payment_failed_permanently_nonref, + failure: failure_nonref.into_native(), + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, + short_channel_id: local_short_channel_id_nonref, + } + }, + Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut path_nonref = Clone::clone(path); + nativeEvent::ProbeSuccessful { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, + } + }, + Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut path_nonref = Clone::clone(path); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; + nativeEvent::ProbeFailed { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, + short_channel_id: local_short_channel_id_nonref, + } + }, + Event::PendingHTLCsForwardable {ref time_forwardable, } => { + let mut time_forwardable_nonref = Clone::clone(time_forwardable); + nativeEvent::PendingHTLCsForwardable { + time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref), + } + }, + Event::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { + let mut intercept_id_nonref = Clone::clone(intercept_id); + let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); + let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); + nativeEvent::HTLCIntercepted { + intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data), + requested_next_hop_scid: requested_next_hop_scid_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + inbound_amount_msat: inbound_amount_msat_nonref, + expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, + } + }, + Event::SpendableOutputs {ref outputs, } => { + let mut outputs_nonref = Clone::clone(outputs); + let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); }; + nativeEvent::SpendableOutputs { + outputs: local_outputs_nonref, + } + }, + Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { + let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); + let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) }; + let mut next_channel_id_nonref = Clone::clone(next_channel_id); + let mut local_next_channel_id_nonref = if next_channel_id_nonref.data == [0; 32] { None } else { Some( { next_channel_id_nonref.data }) }; + let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); + let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None }; + let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); + let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); + let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None }; + nativeEvent::PaymentForwarded { + prev_channel_id: local_prev_channel_id_nonref, + next_channel_id: local_next_channel_id_nonref, + fee_earned_msat: local_fee_earned_msat_nonref, + claim_from_onchain_tx: claim_from_onchain_tx_nonref, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, + } + }, + Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.data == [0; 32] { None } else { Some( { former_temporary_channel_id_nonref.data }) }; + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + nativeEvent::ChannelPending { + channel_id: channel_id_nonref.data, + user_channel_id: user_channel_id_nonref.into(), + former_temporary_channel_id: local_former_temporary_channel_id_nonref, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), + } + }, + Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut channel_type_nonref = Clone::clone(channel_type); + nativeEvent::ChannelReady { + channel_id: channel_id_nonref.data, + user_channel_id: user_channel_id_nonref.into(), + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, + } + }, + Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut reason_nonref = Clone::clone(reason); + nativeEvent::ChannelClosed { + channel_id: channel_id_nonref.data, + user_channel_id: user_channel_id_nonref.into(), + reason: reason_nonref.into_native(), + } + }, + Event::DiscardFunding {ref channel_id, ref transaction, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut transaction_nonref = Clone::clone(transaction); + nativeEvent::DiscardFunding { + channel_id: channel_id_nonref.data, + transaction: transaction_nonref.into_bitcoin(), + } + }, + Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); + let mut push_msat_nonref = Clone::clone(push_msat); + let mut channel_type_nonref = Clone::clone(channel_type); + nativeEvent::OpenChannelRequest { + temporary_channel_id: temporary_channel_id_nonref.data, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + funding_satoshis: funding_satoshis_nonref, + push_msat: push_msat_nonref, + channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, + } + }, + Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { + let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); + let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); + nativeEvent::HTLCHandlingFailed { + prev_channel_id: prev_channel_id_nonref.data, + failed_next_destination: failed_next_destination_nonref.into_native(), + } + }, + Event::BumpTransaction (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeEvent::BumpTransaction ( + a_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeEvent { + match self { + Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { + nativeEvent::FundingGenerationReady { + temporary_channel_id: temporary_channel_id.data, + counterparty_node_id: counterparty_node_id.into_rust(), + channel_value_satoshis: channel_value_satoshis, + output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()), + user_channel_id: user_channel_id.into(), + } + }, + Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { + let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; + let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; + let mut local_via_channel_id = if via_channel_id.data == [0; 32] { None } else { Some( { via_channel_id.data }) }; + let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} }; + let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None }; + nativeEvent::PaymentClaimable { + receiver_node_id: local_receiver_node_id, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + onion_fields: local_onion_fields, + amount_msat: amount_msat, + counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat, + purpose: purpose.into_native(), + via_channel_id: local_via_channel_id, + via_user_channel_id: local_via_user_channel_id, + claim_deadline: local_claim_deadline, + } + }, + Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { + let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; + nativeEvent::PaymentClaimed { + receiver_node_id: local_receiver_node_id, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + amount_msat: amount_msat, + purpose: purpose.into_native(), + } + }, + Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { + let mut local_payment_id = { /*payment_id*/ let payment_id_opt = payment_id; if payment_id_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_opt.take() }.data) }})} }; + let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None }; + nativeEvent::PaymentSent { + payment_id: local_payment_id, + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + fee_paid_msat: local_fee_paid_msat, + } + }, + Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} }; + nativeEvent::PaymentFailed { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + reason: local_reason, + } + }, + Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; + nativeEvent::PaymentPathSuccessful { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + payment_hash: local_payment_hash, + path: *unsafe { Box::from_raw(path.take_inner()) }, + } + }, + Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { + let mut local_payment_id = { /*payment_id*/ let payment_id_opt = payment_id; if payment_id_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_opt.take() }.data) }})} }; + let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; + nativeEvent::PaymentPathFailed { + payment_id: local_payment_id, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_failed_permanently: payment_failed_permanently, + failure: failure.into_native(), + path: *unsafe { Box::from_raw(path.take_inner()) }, + short_channel_id: local_short_channel_id, + } + }, + Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { + nativeEvent::ProbeSuccessful { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + path: *unsafe { Box::from_raw(path.take_inner()) }, + } + }, + Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { + let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; + nativeEvent::ProbeFailed { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + path: *unsafe { Box::from_raw(path.take_inner()) }, + short_channel_id: local_short_channel_id, + } + }, + Event::PendingHTLCsForwardable {mut time_forwardable, } => { + nativeEvent::PendingHTLCsForwardable { + time_forwardable: core::time::Duration::from_secs(time_forwardable), + } + }, + Event::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { + nativeEvent::HTLCIntercepted { + intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data), + requested_next_hop_scid: requested_next_hop_scid, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + inbound_amount_msat: inbound_amount_msat, + expected_outbound_amount_msat: expected_outbound_amount_msat, + } + }, + Event::SpendableOutputs {mut outputs, } => { + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); }; + nativeEvent::SpendableOutputs { + outputs: local_outputs, + } + }, + Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { + let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) }; + let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) }; + let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None }; + let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None }; + nativeEvent::PaymentForwarded { + prev_channel_id: local_prev_channel_id, + next_channel_id: local_next_channel_id, + fee_earned_msat: local_fee_earned_msat, + claim_from_onchain_tx: claim_from_onchain_tx, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, + } + }, + Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { + let mut local_former_temporary_channel_id = if former_temporary_channel_id.data == [0; 32] { None } else { Some( { former_temporary_channel_id.data }) }; + nativeEvent::ChannelPending { + channel_id: channel_id.data, + user_channel_id: user_channel_id.into(), + former_temporary_channel_id: local_former_temporary_channel_id, + counterparty_node_id: counterparty_node_id.into_rust(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), + } + }, + Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { + nativeEvent::ChannelReady { + channel_id: channel_id.data, + user_channel_id: user_channel_id.into(), + counterparty_node_id: counterparty_node_id.into_rust(), + channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, + } + }, + Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { + nativeEvent::ChannelClosed { + channel_id: channel_id.data, + user_channel_id: user_channel_id.into(), + reason: reason.into_native(), + } + }, + Event::DiscardFunding {mut channel_id, mut transaction, } => { + nativeEvent::DiscardFunding { + channel_id: channel_id.data, + transaction: transaction.into_bitcoin(), + } + }, + Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + nativeEvent::OpenChannelRequest { + temporary_channel_id: temporary_channel_id.data, + counterparty_node_id: counterparty_node_id.into_rust(), + funding_satoshis: funding_satoshis, + push_msat: push_msat, + channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, + } + }, + Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { + nativeEvent::HTLCHandlingFailed { + prev_channel_id: prev_channel_id.data, + failed_next_destination: failed_next_destination.into_native(), + } + }, + Event::BumpTransaction (mut a, ) => { + nativeEvent::BumpTransaction ( + a.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeEvent) -> Self { + match native { + nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { + let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); + let mut output_script_nonref = Clone::clone(output_script); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + Event::FundingGenerationReady { + temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + channel_value_satoshis: channel_value_satoshis_nonref, + output_script: output_script_nonref.into_bytes().into(), + user_channel_id: user_channel_id_nonref.into(), + } + }, + nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { + let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); + let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true }; + let mut amount_msat_nonref = Clone::clone(amount_msat); + let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat); + let mut purpose_nonref = Clone::clone(purpose); + let mut via_channel_id_nonref = Clone::clone(via_channel_id); + let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id_nonref.unwrap()) } } }; + let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); + let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) }; + let mut claim_deadline_nonref = Clone::clone(claim_deadline); + let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline_nonref.unwrap() }) }; + Event::PaymentClaimable { + receiver_node_id: local_receiver_node_id_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + onion_fields: local_onion_fields_nonref, + amount_msat: amount_msat_nonref, + counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref, + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), + via_channel_id: local_via_channel_id_nonref, + via_user_channel_id: local_via_user_channel_id_nonref, + claim_deadline: local_claim_deadline_nonref, + } + }, + nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { + let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); + let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut amount_msat_nonref = Clone::clone(amount_msat); + let mut purpose_nonref = Clone::clone(purpose); + Event::PaymentClaimed { + receiver_node_id: local_receiver_node_id_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + amount_msat: amount_msat_nonref, + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), + } + }, + nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::derived::COption_PaymentIdZ::None } else { crate::c_types::derived::COption_PaymentIdZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.unwrap().0 } }) }; + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); + let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat_nonref.unwrap() }) }; + Event::PaymentSent { + payment_id: local_payment_id_nonref, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + fee_paid_msat: local_fee_paid_msat_nonref, + } + }, + nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut reason_nonref = Clone::clone(reason); + let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) }; + Event::PaymentFailed { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + reason: local_reason_nonref, + } + }, + nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) }; + let mut path_nonref = Clone::clone(path); + Event::PaymentPathSuccessful { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + payment_hash: local_payment_hash_nonref, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, + } + }, + nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::derived::COption_PaymentIdZ::None } else { crate::c_types::derived::COption_PaymentIdZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.unwrap().0 } }) }; + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); + let mut failure_nonref = Clone::clone(failure); + let mut path_nonref = Clone::clone(path); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; + Event::PaymentPathFailed { + payment_id: local_payment_id_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + payment_failed_permanently: payment_failed_permanently_nonref, + failure: crate::lightning::events::PathFailure::native_into(failure_nonref), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, + short_channel_id: local_short_channel_id_nonref, + } + }, + nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut path_nonref = Clone::clone(path); + Event::ProbeSuccessful { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, + } + }, + nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut path_nonref = Clone::clone(path); + let mut short_channel_id_nonref = Clone::clone(short_channel_id); + let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; + Event::ProbeFailed { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, + short_channel_id: local_short_channel_id_nonref, + } + }, + nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => { + let mut time_forwardable_nonref = Clone::clone(time_forwardable); + Event::PendingHTLCsForwardable { + time_forwardable: time_forwardable_nonref.as_secs(), + } + }, + nativeEvent::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { + let mut intercept_id_nonref = Clone::clone(intercept_id); + let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); + let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); + Event::HTLCIntercepted { + intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id_nonref.0 }, + requested_next_hop_scid: requested_next_hop_scid_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + inbound_amount_msat: inbound_amount_msat_nonref, + expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, + } + }, + nativeEvent::SpendableOutputs {ref outputs, } => { + let mut outputs_nonref = Clone::clone(outputs); + let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); }; + Event::SpendableOutputs { + outputs: local_outputs_nonref.into(), + } + }, + nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { + let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); + let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } }; + let mut next_channel_id_nonref = Clone::clone(next_channel_id); + let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id_nonref.unwrap()) } } }; + let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); + let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) }; + let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); + let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); + let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) }; + Event::PaymentForwarded { + prev_channel_id: local_prev_channel_id_nonref, + next_channel_id: local_next_channel_id_nonref, + fee_earned_msat: local_fee_earned_msat_nonref, + claim_from_onchain_tx: claim_from_onchain_tx_nonref, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, + } + }, + nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id_nonref.unwrap()) } } }; + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + Event::ChannelPending { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + user_channel_id: user_channel_id_nonref.into(), + former_temporary_channel_id: local_former_temporary_channel_id_nonref, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref), + } + }, + nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut channel_type_nonref = Clone::clone(channel_type); + Event::ChannelReady { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + user_channel_id: user_channel_id_nonref.into(), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + } + }, + nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut reason_nonref = Clone::clone(reason); + Event::ChannelClosed { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + user_channel_id: user_channel_id_nonref.into(), + reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), + } + }, + nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut transaction_nonref = Clone::clone(transaction); + Event::DiscardFunding { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), + } + }, + nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); + let mut push_msat_nonref = Clone::clone(push_msat); + let mut channel_type_nonref = Clone::clone(channel_type); + Event::OpenChannelRequest { + temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + funding_satoshis: funding_satoshis_nonref, + push_msat: push_msat_nonref, + channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + } + }, + nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { + let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); + let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); + Event::HTLCHandlingFailed { + prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref }, + failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref), + } + }, + nativeEvent::BumpTransaction (ref a, ) => { + let mut a_nonref = Clone::clone(a); + Event::BumpTransaction ( + crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeEvent) -> Self { + match native { + nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { + Event::FundingGenerationReady { + temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + channel_value_satoshis: channel_value_satoshis, + output_script: output_script.into_bytes().into(), + user_channel_id: user_channel_id.into(), + } + }, + nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { + let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; + let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; + let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id.unwrap()) } } }; + let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id.unwrap().into() }) }; + let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) }; + Event::PaymentClaimable { + receiver_node_id: local_receiver_node_id, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + onion_fields: local_onion_fields, + amount_msat: amount_msat, + counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat, + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), + via_channel_id: local_via_channel_id, + via_user_channel_id: local_via_user_channel_id, + claim_deadline: local_claim_deadline, + } + }, + nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { + let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; + Event::PaymentClaimed { + receiver_node_id: local_receiver_node_id, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + amount_msat: amount_msat, + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), + } + }, + nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { + let mut local_payment_id = if payment_id.is_none() { crate::c_types::derived::COption_PaymentIdZ::None } else { crate::c_types::derived::COption_PaymentIdZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id.unwrap().0 } }) }; + let mut local_fee_paid_msat = if fee_paid_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat.unwrap() }) }; + Event::PaymentSent { + payment_id: local_payment_id, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + fee_paid_msat: local_fee_paid_msat, + } + }, + nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) }; + Event::PaymentFailed { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + reason: local_reason, + } + }, + nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { + let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) }; + Event::PaymentPathSuccessful { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + payment_hash: local_payment_hash, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, + } + }, + nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { + let mut local_payment_id = if payment_id.is_none() { crate::c_types::derived::COption_PaymentIdZ::None } else { crate::c_types::derived::COption_PaymentIdZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id.unwrap().0 } }) }; + let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; + Event::PaymentPathFailed { + payment_id: local_payment_id, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + payment_failed_permanently: payment_failed_permanently, + failure: crate::lightning::events::PathFailure::native_into(failure), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, + short_channel_id: local_short_channel_id, + } + }, + nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { + Event::ProbeSuccessful { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, + } + }, + nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { + let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; + Event::ProbeFailed { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, + short_channel_id: local_short_channel_id, + } + }, + nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => { + Event::PendingHTLCsForwardable { + time_forwardable: time_forwardable.as_secs(), + } + }, + nativeEvent::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { + Event::HTLCIntercepted { + intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id.0 }, + requested_next_hop_scid: requested_next_hop_scid, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + inbound_amount_msat: inbound_amount_msat, + expected_outbound_amount_msat: expected_outbound_amount_msat, + } + }, + nativeEvent::SpendableOutputs {mut outputs, } => { + let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); }; + Event::SpendableOutputs { + outputs: local_outputs.into(), + } + }, + nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { + let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id.unwrap()) } } }; + let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id.unwrap()) } } }; + let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) }; + let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) }; + Event::PaymentForwarded { + prev_channel_id: local_prev_channel_id, + next_channel_id: local_next_channel_id, + fee_earned_msat: local_fee_earned_msat, + claim_from_onchain_tx: claim_from_onchain_tx, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, + } + }, + nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { + let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id.unwrap()) } } }; + Event::ChannelPending { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + user_channel_id: user_channel_id.into(), + former_temporary_channel_id: local_former_temporary_channel_id, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo), + } + }, + nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { + Event::ChannelReady { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + user_channel_id: user_channel_id.into(), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + } + }, + nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { + Event::ChannelClosed { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + user_channel_id: user_channel_id.into(), + reason: crate::lightning::events::ClosureReason::native_into(reason), + } + }, + nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { + Event::DiscardFunding { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + transaction: crate::c_types::Transaction::from_bitcoin(&transaction), + } + }, + nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + Event::OpenChannelRequest { + temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + funding_satoshis: funding_satoshis, + push_msat: push_msat, + channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + } + }, + nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { + Event::HTLCHandlingFailed { + prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id }, + failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination), + } + }, + nativeEvent::BumpTransaction (mut a, ) => { + Event::BumpTransaction ( + crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a), + ) + }, + } + } +} +/// Frees any resources used by the Event +#[no_mangle] +pub extern "C" fn Event_free(this_ptr: Event) { } +/// Creates a copy of the Event +#[no_mangle] +pub extern "C" fn Event_clone(orig: &Event) -> Event { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new FundingGenerationReady-variant Event +pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: crate::c_types::U128) -> Event { + Event::FundingGenerationReady { + temporary_channel_id, + counterparty_node_id, + channel_value_satoshis, + output_script, + user_channel_id, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentClaimable-variant Event +pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, counterparty_skimmed_fee_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::ThirtyTwoBytes, via_user_channel_id: crate::c_types::derived::COption_u128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { + Event::PaymentClaimable { + receiver_node_id, + payment_hash, + onion_fields, + amount_msat, + counterparty_skimmed_fee_msat, + purpose, + via_channel_id, + via_user_channel_id, + claim_deadline, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentClaimed-variant Event +pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose) -> Event { + Event::PaymentClaimed { + receiver_node_id, + payment_hash, + amount_msat, + purpose, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentSent-variant Event +pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::derived::COption_PaymentIdZ, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event { + Event::PaymentSent { + payment_id, + payment_preimage, + payment_hash, + fee_paid_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentFailed-variant Event +pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { + Event::PaymentFailed { + payment_id, + payment_hash, + reason, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentPathSuccessful-variant Event +pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_PaymentHashZ, path: crate::lightning::routing::router::Path) -> Event { + Event::PaymentPathSuccessful { + payment_id, + payment_hash, + path, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentPathFailed-variant Event +pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::derived::COption_PaymentIdZ, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::events::PathFailure, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { + Event::PaymentPathFailed { + payment_id, + payment_hash, + payment_failed_permanently, + failure, + path, + short_channel_id, + } +} +#[no_mangle] +/// Utility method to constructs a new ProbeSuccessful-variant Event +pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { + Event::ProbeSuccessful { + payment_id, + payment_hash, + path, + } +} +#[no_mangle] +/// Utility method to constructs a new ProbeFailed-variant Event +pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { + Event::ProbeFailed { + payment_id, + payment_hash, + path, + short_channel_id, + } +} +#[no_mangle] +/// Utility method to constructs a new PendingHTLCsForwardable-variant Event +pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event { + Event::PendingHTLCsForwardable { + time_forwardable, + } +} +#[no_mangle] +/// Utility method to constructs a new HTLCIntercepted-variant Event +pub extern "C" fn Event_htlcintercepted(intercept_id: crate::c_types::ThirtyTwoBytes, requested_next_hop_scid: u64, payment_hash: crate::c_types::ThirtyTwoBytes, inbound_amount_msat: u64, expected_outbound_amount_msat: u64) -> Event { + Event::HTLCIntercepted { + intercept_id, + requested_next_hop_scid, + payment_hash, + inbound_amount_msat, + expected_outbound_amount_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new SpendableOutputs-variant Event +pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ) -> Event { + Event::SpendableOutputs { + outputs, + } +} +#[no_mangle] +/// Utility method to constructs a new PaymentForwarded-variant Event +pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { + Event::PaymentForwarded { + prev_channel_id, + next_channel_id, + fee_earned_msat, + claim_from_onchain_tx, + outbound_amount_forwarded_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new ChannelPending-variant Event +pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { + Event::ChannelPending { + channel_id, + user_channel_id, + former_temporary_channel_id, + counterparty_node_id, + funding_txo, + } +} +#[no_mangle] +/// Utility method to constructs a new ChannelReady-variant Event +pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { + Event::ChannelReady { + channel_id, + user_channel_id, + counterparty_node_id, + channel_type, + } +} +#[no_mangle] +/// Utility method to constructs a new ChannelClosed-variant Event +pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason) -> Event { + Event::ChannelClosed { + channel_id, + user_channel_id, + reason, + } +} +#[no_mangle] +/// Utility method to constructs a new DiscardFunding-variant Event +pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event { + Event::DiscardFunding { + channel_id, + transaction, + } +} +#[no_mangle] +/// Utility method to constructs a new OpenChannelRequest-variant Event +pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { + Event::OpenChannelRequest { + temporary_channel_id, + counterparty_node_id, + funding_satoshis, + push_msat, + channel_type, + } +} +#[no_mangle] +/// Utility method to constructs a new HTLCHandlingFailed-variant Event +pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { + Event::HTLCHandlingFailed { + prev_channel_id, + failed_next_destination, + } +} +#[no_mangle] +/// Utility method to constructs a new BumpTransaction-variant Event +pub extern "C" fn Event_bump_transaction(a: crate::lightning::events::bump_transaction::BumpTransactionEvent) -> Event { + Event::BumpTransaction(a, ) +} +/// Checks if two Events contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the Event object into a byte array which can be read by Event_read +pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a Event from a byte array, created by Event_write +pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// An event generated by ChannelManager which indicates a message should be sent to a peer (or +/// broadcast to most peers). +/// These events are handled by PeerManager::process_events if you are using a PeerManager. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MessageSendEvent { + /// Used to indicate that we've accepted a channel open and should send the accept_channel + /// message provided to the given peer. + SendAcceptChannel { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::AcceptChannel, + }, + /// Used to indicate that we've accepted a V2 channel open and should send the accept_channel2 + /// message provided to the given peer. + SendAcceptChannelV2 { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::AcceptChannelV2, + }, + /// Used to indicate that we've initiated a channel open and should send the open_channel + /// message provided to the given peer. + SendOpenChannel { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::OpenChannel, + }, + /// Used to indicate that we've initiated a V2 channel open and should send the open_channel2 + /// message provided to the given peer. + SendOpenChannelV2 { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::OpenChannelV2, + }, + /// Used to indicate that a funding_created message should be sent to the peer with the given node_id. + SendFundingCreated { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::FundingCreated, + }, + /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + SendFundingSigned { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::FundingSigned, + }, + /// Used to indicate that a tx_add_input message should be sent to the peer with the given node_id. + SendTxAddInput { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxAddInput, + }, + /// Used to indicate that a tx_add_output message should be sent to the peer with the given node_id. + SendTxAddOutput { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxAddOutput, + }, + /// Used to indicate that a tx_remove_input message should be sent to the peer with the given node_id. + SendTxRemoveInput { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxRemoveInput, + }, + /// Used to indicate that a tx_remove_output message should be sent to the peer with the given node_id. + SendTxRemoveOutput { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxRemoveOutput, + }, + /// Used to indicate that a tx_complete message should be sent to the peer with the given node_id. + SendTxComplete { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxComplete, + }, + /// Used to indicate that a tx_signatures message should be sent to the peer with the given node_id. + SendTxSignatures { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxSignatures, + }, + /// Used to indicate that a tx_init_rbf message should be sent to the peer with the given node_id. + SendTxInitRbf { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxInitRbf, + }, + /// Used to indicate that a tx_ack_rbf message should be sent to the peer with the given node_id. + SendTxAckRbf { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxAckRbf, + }, + /// Used to indicate that a tx_abort message should be sent to the peer with the given node_id. + SendTxAbort { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::TxAddInput, + }, + /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id. + SendChannelReady { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The channel_ready message which should be sent. + msg: crate::lightning::ln::msgs::ChannelReady, + }, + /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + SendAnnouncementSignatures { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The announcement_signatures message which should be sent. + msg: crate::lightning::ln::msgs::AnnouncementSignatures, + }, + /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed + /// message should be sent to the peer with the given node_id. + UpdateHTLCs { + /// The node_id of the node which should receive these message(s) + node_id: crate::c_types::PublicKey, + /// The update messages which should be sent. ALL messages in the struct should be sent! + updates: crate::lightning::ln::msgs::CommitmentUpdate, + }, + /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + SendRevokeAndACK { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::RevokeAndACK, + }, + /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + SendClosingSigned { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::ClosingSigned, + }, + /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. + SendShutdown { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::Shutdown, + }, + /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + SendChannelReestablish { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The message which should be sent. + msg: crate::lightning::ln::msgs::ChannelReestablish, + }, + /// Used to send a channel_announcement and channel_update to a specific peer, likely on + /// initial connection to ensure our peers know about our channels. + SendChannelAnnouncement { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The channel_announcement which should be sent. + msg: crate::lightning::ln::msgs::ChannelAnnouncement, + /// The followup channel_update which should be sent. + update_msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Used to indicate that a channel_announcement and channel_update should be broadcast to all + /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). + /// + /// Note that after doing so, you very likely (unless you did so very recently) want to + /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This + /// ensures that any nodes which see our channel_announcement also have a relevant + /// node_announcement, including relevant feature flags which may be important for routing + /// through or to us. + /// + /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement + BroadcastChannelAnnouncement { + /// The channel_announcement which should be sent. + msg: crate::lightning::ln::msgs::ChannelAnnouncement, + /// The followup channel_update which should be sent. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + update_msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Used to indicate that a channel_update should be broadcast to all peers. + BroadcastChannelUpdate { + /// The channel_update which should be sent. + msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Used to indicate that a node_announcement should be broadcast to all peers. + BroadcastNodeAnnouncement { + /// The node_announcement which should be sent. + msg: crate::lightning::ln::msgs::NodeAnnouncement, + }, + /// Used to indicate that a channel_update should be sent to a single peer. + /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a + /// private channel and we shouldn't be informing all of our peers of channel parameters. + SendChannelUpdate { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The channel_update which should be sent. + msg: crate::lightning::ln::msgs::ChannelUpdate, + }, + /// Broadcast an error downstream to be handled + HandleError { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The action which should be taken. + action: crate::lightning::ln::msgs::ErrorAction, + }, + /// Query a peer for channels with funding transaction UTXOs in a block range. + SendChannelRangeQuery { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The query_channel_range which should be sent. + msg: crate::lightning::ln::msgs::QueryChannelRange, + }, + /// Request routing gossip messages from a peer for a list of channels identified by + /// their short_channel_ids. + SendShortIdsQuery { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The query_short_channel_ids which should be sent. + msg: crate::lightning::ln::msgs::QueryShortChannelIds, + }, + /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + /// emitted during processing of the query. + SendReplyChannelRange { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The reply_channel_range which should be sent. + msg: crate::lightning::ln::msgs::ReplyChannelRange, + }, + /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to + /// enable receiving gossip messages from the peer. + SendGossipTimestampFilter { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The gossip_timestamp_filter which should be sent. + msg: crate::lightning::ln::msgs::GossipTimestampFilter, + }, +} +use lightning::events::MessageSendEvent as MessageSendEventImport; +pub(crate) type nativeMessageSendEvent = MessageSendEventImport; + +impl MessageSendEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMessageSendEvent { + match self { + MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendAcceptChannel { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendAcceptChannelV2 { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendOpenChannel { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendOpenChannelV2 { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendFundingCreated { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendFundingSigned { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxAddInput { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxAddOutput { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxRemoveInput { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxRemoveOutput { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxComplete {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxComplete { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxSignatures { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxInitRbf { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxAckRbf { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendTxAbort {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendTxAbort { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendChannelReady { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendAnnouncementSignatures { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut updates_nonref = Clone::clone(updates); + nativeMessageSendEvent::UpdateHTLCs { + node_id: node_id_nonref.into_rust(), + updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendRevokeAndACK { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendClosingSigned { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendShutdown {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendShutdown { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendChannelReestablish { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + let mut update_msg_nonref = Clone::clone(update_msg); + nativeMessageSendEvent::SendChannelAnnouncement { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { + let mut msg_nonref = Clone::clone(msg); + let mut update_msg_nonref = Clone::clone(update_msg); + let mut local_update_msg_nonref = if update_msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg_nonref.take_inner()) } }) }; + nativeMessageSendEvent::BroadcastChannelAnnouncement { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + update_msg: local_update_msg_nonref, + } + }, + MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::BroadcastChannelUpdate { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::BroadcastNodeAnnouncement { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendChannelUpdate { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::HandleError {ref node_id, ref action, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut action_nonref = Clone::clone(action); + nativeMessageSendEvent::HandleError { + node_id: node_id_nonref.into_rust(), + action: action_nonref.into_native(), + } + }, + MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + nativeMessageSendEvent::SendGossipTimestampFilter { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMessageSendEvent { + match self { + MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendAcceptChannel { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendAcceptChannelV2 { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendOpenChannel { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendOpenChannelV2 { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendFundingCreated { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendFundingSigned { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxAddInput { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxAddOutput { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxRemoveInput { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxRemoveOutput { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxComplete {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxComplete { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxSignatures { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxInitRbf { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxAckRbf { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendTxAbort {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendTxAbort { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelReady { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendAnnouncementSignatures { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { + nativeMessageSendEvent::UpdateHTLCs { + node_id: node_id.into_rust(), + updates: *unsafe { Box::from_raw(updates.take_inner()) }, + } + }, + MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendRevokeAndACK { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendClosingSigned { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendShutdown { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelReestablish { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { + nativeMessageSendEvent::SendChannelAnnouncement { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, + } + }, + MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { + let mut local_update_msg = if update_msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg.take_inner()) } }) }; + nativeMessageSendEvent::BroadcastChannelAnnouncement { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + update_msg: local_update_msg, + } + }, + MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { + nativeMessageSendEvent::BroadcastChannelUpdate { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { + nativeMessageSendEvent::BroadcastNodeAnnouncement { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelUpdate { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::HandleError {mut node_id, mut action, } => { + nativeMessageSendEvent::HandleError { + node_id: node_id.into_rust(), + action: action.into_native(), + } + }, + MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelRangeQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendShortIdsQuery { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendGossipTimestampFilter { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self { + match native { + nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendAcceptChannel { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendAcceptChannelV2 { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendOpenChannel { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendOpenChannelV2 { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendFundingCreated { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendFundingSigned { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxAddInput { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxAddOutput { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxRemoveInput { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxRemoveOutput { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxComplete {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxComplete { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxSignatures { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxInitRbf { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxAckRbf { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAbort {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendTxAbort { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendChannelReady { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendAnnouncementSignatures { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut updates_nonref = Clone::clone(updates); + MessageSendEvent::UpdateHTLCs { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendRevokeAndACK { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendClosingSigned { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendShutdown { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendChannelReestablish { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + let mut update_msg_nonref = Clone::clone(update_msg); + MessageSendEvent::SendChannelAnnouncement { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { + let mut msg_nonref = Clone::clone(msg); + let mut update_msg_nonref = Clone::clone(update_msg); + let mut local_update_msg_nonref = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg_nonref.unwrap())) } }, is_owned: true }; + MessageSendEvent::BroadcastChannelAnnouncement { + msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + update_msg: local_update_msg_nonref, + } + }, + nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::BroadcastChannelUpdate { + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::BroadcastNodeAnnouncement { + msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendChannelUpdate { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::HandleError {ref node_id, ref action, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut action_nonref = Clone::clone(action); + MessageSendEvent::HandleError { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref), + } + }, + nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut msg_nonref = Clone::clone(msg); + MessageSendEvent::SendGossipTimestampFilter { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self { + match native { + nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { + MessageSendEvent::SendAcceptChannel { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => { + MessageSendEvent::SendAcceptChannelV2 { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { + MessageSendEvent::SendOpenChannel { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => { + MessageSendEvent::SendOpenChannelV2 { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { + MessageSendEvent::SendFundingCreated { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { + MessageSendEvent::SendFundingSigned { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => { + MessageSendEvent::SendTxAddInput { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => { + MessageSendEvent::SendTxAddOutput { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => { + MessageSendEvent::SendTxRemoveInput { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => { + MessageSendEvent::SendTxRemoveOutput { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxComplete {mut node_id, mut msg, } => { + MessageSendEvent::SendTxComplete { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => { + MessageSendEvent::SendTxSignatures { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => { + MessageSendEvent::SendTxInitRbf { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => { + MessageSendEvent::SendTxAckRbf { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendTxAbort {mut node_id, mut msg, } => { + MessageSendEvent::SendTxAbort { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelReady { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { + MessageSendEvent::SendAnnouncementSignatures { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { + MessageSendEvent::UpdateHTLCs { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true }, + } + }, + nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { + MessageSendEvent::SendRevokeAndACK { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { + MessageSendEvent::SendClosingSigned { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => { + MessageSendEvent::SendShutdown { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelReestablish { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { + MessageSendEvent::SendChannelAnnouncement { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, + update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { + let mut local_update_msg = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg.unwrap())) } }, is_owned: true }; + MessageSendEvent::BroadcastChannelAnnouncement { + msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, + update_msg: local_update_msg, + } + }, + nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => { + MessageSendEvent::BroadcastChannelUpdate { + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { + MessageSendEvent::BroadcastNodeAnnouncement { + msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelUpdate { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::HandleError {mut node_id, mut action, } => { + MessageSendEvent::HandleError { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + action: crate::lightning::ln::msgs::ErrorAction::native_into(action), + } + }, + nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelRangeQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { + MessageSendEvent::SendShortIdsQuery { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { + MessageSendEvent::SendGossipTimestampFilter { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the MessageSendEvent +#[no_mangle] +pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { } +/// Creates a copy of the MessageSendEvent +#[no_mangle] +pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent { + MessageSendEvent::SendAcceptChannel { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_accept_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannelV2) -> MessageSendEvent { + MessageSendEvent::SendAcceptChannelV2 { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent { + MessageSendEvent::SendOpenChannel { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_open_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannelV2) -> MessageSendEvent { + MessageSendEvent::SendOpenChannelV2 { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent { + MessageSendEvent::SendFundingCreated { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent { + MessageSendEvent::SendFundingSigned { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxAddInput-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_add_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddInput) -> MessageSendEvent { + MessageSendEvent::SendTxAddInput { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_add_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddOutput) -> MessageSendEvent { + MessageSendEvent::SendTxAddOutput { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_remove_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveInput) -> MessageSendEvent { + MessageSendEvent::SendTxRemoveInput { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_remove_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveOutput) -> MessageSendEvent { + MessageSendEvent::SendTxRemoveOutput { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxComplete-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_complete(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxComplete) -> MessageSendEvent { + MessageSendEvent::SendTxComplete { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxSignatures-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxSignatures) -> MessageSendEvent { + MessageSendEvent::SendTxSignatures { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_init_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxInitRbf) -> MessageSendEvent { + MessageSendEvent::SendTxInitRbf { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_ack_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAckRbf) -> MessageSendEvent { + MessageSendEvent::SendTxAckRbf { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendTxAbort-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_tx_abort(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddInput) -> MessageSendEvent { + MessageSendEvent::SendTxAbort { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendChannelReady-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent { + MessageSendEvent::SendChannelReady { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent { + MessageSendEvent::SendAnnouncementSignatures { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent { + MessageSendEvent::UpdateHTLCs { + node_id, + updates, + } +} +#[no_mangle] +/// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent { + MessageSendEvent::SendRevokeAndACK { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent { + MessageSendEvent::SendClosingSigned { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendShutdown-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent { + MessageSendEvent::SendShutdown { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent { + MessageSendEvent::SendChannelReestablish { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { + MessageSendEvent::SendChannelAnnouncement { + node_id, + msg, + update_msg, + } +} +#[no_mangle] +/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { + MessageSendEvent::BroadcastChannelAnnouncement { + msg, + update_msg, + } +} +#[no_mangle] +/// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { + MessageSendEvent::BroadcastChannelUpdate { + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent { + MessageSendEvent::BroadcastNodeAnnouncement { + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { + MessageSendEvent::SendChannelUpdate { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new HandleError-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent { + MessageSendEvent::HandleError { + node_id, + action, + } +} +#[no_mangle] +/// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent { + MessageSendEvent::SendChannelRangeQuery { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent { + MessageSendEvent::SendShortIdsQuery { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent { + MessageSendEvent::SendReplyChannelRange { + node_id, + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent { + MessageSendEvent::SendGossipTimestampFilter { + node_id, + msg, + } +} +/// A trait indicating an object may generate message send events +#[repr(C)] +pub struct MessageSendEventsProvider { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Gets the list of pending events which were generated by previous actions, clearing the list + /// in the process. + pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for MessageSendEventsProvider {} +unsafe impl Sync for MessageSendEventsProvider {} +#[no_mangle] +pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider { + MessageSendEventsProvider { + this_arg: orig.this_arg, + get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider; +impl rustMessageSendEventsProvider for MessageSendEventsProvider { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for MessageSendEventsProvider { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { } +impl Drop for MessageSendEventsProvider { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait indicating an object may generate onion messages to send +#[repr(C)] +pub struct OnionMessageProvider { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Gets the next pending onion message for the peer with the given node id. + /// + /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for OnionMessageProvider {} +unsafe impl Sync for OnionMessageProvider {} +#[no_mangle] +pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider { + OnionMessageProvider { + this_arg: orig.this_arg, + next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::OnionMessageProvider as rustOnionMessageProvider; +impl rustOnionMessageProvider for OnionMessageProvider { + fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { + let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id)); + let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for OnionMessageProvider { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { } +impl Drop for OnionMessageProvider { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait indicating an object may generate events. +/// +/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. +/// +/// Implementations of this trait may also feature an async version of event handling, as shown with +/// [`ChannelManager::process_pending_events_async`] and +/// [`ChainMonitor::process_pending_events_async`]. +/// +/// # Requirements +/// +/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending +/// event since the last invocation. +/// +/// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s +/// and replay any unhandled events on startup. An [`Event`] is considered handled when +/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any +/// relevant changes to disk *before* returning. +/// +/// Further, because an application may crash between an [`Event`] being handled and the +/// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in +/// effect, [`Event`]s may be replayed. +/// +/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to +/// consult the provider's documentation on the implication of processing events and how a handler +/// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and +/// [`ChainMonitor::process_pending_events`]). +/// +/// (C-not implementable) As there is likely no reason for a user to implement this trait on their +/// own type(s). +/// +/// [`process_pending_events`]: Self::process_pending_events +/// [`handle_event`]: EventHandler::handle_event +/// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events +/// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events +/// [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async +/// [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async +#[repr(C)] +pub struct EventsProvider { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Processes any events generated since the last call using the given event handler. + /// + /// See the trait-level documentation for requirements. + pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for EventsProvider {} +unsafe impl Sync for EventsProvider {} +#[no_mangle] +pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider { + EventsProvider { + this_arg: orig.this_arg, + process_pending_events: Clone::clone(&orig.process_pending_events), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::EventsProvider as rustEventsProvider; +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { } +impl Drop for EventsProvider { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait implemented for objects handling events from [`EventsProvider`]. +/// +/// An async variation also exists for implementations of [`EventsProvider`] that support async +/// event handling. The async event handler should satisfy the generic bounds: `F: +/// core::future::Future, H: Fn(Event) -> F`. +#[repr(C)] +pub struct EventHandler { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Handles the given [`Event`]. + /// + /// See [`EventsProvider`] for details that must be considered when implementing this method. + pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for EventHandler {} +unsafe impl Sync for EventHandler {} +#[no_mangle] +pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler { + EventHandler { + this_arg: orig.this_arg, + handle_event: Clone::clone(&orig.handle_event), + free: Clone::clone(&orig.free), + } +} + +use lightning::events::EventHandler as rustEventHandler; +impl rustEventHandler for EventHandler { + fn handle_event(&self, mut event: lightning::events::Event) { + (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)) + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for EventHandler { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { } +impl Drop for EventHandler { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index ebfd129..b6a68d6 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -7,7 +7,7 @@ // source was automatically generated. //! Various utilities for building scripts and deriving keys related to channels. These are -//! largely of interest for those implementing the traits on [`chain::keysinterface`] by hand. +//! largely of interest for those implementing the traits on [`crate::sign`] by hand. use alloc::str::FromStr; use core::ffi::c_void; @@ -35,17 +35,31 @@ pub static OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS: usize = lightning::ln::chan_utils #[no_mangle] pub static MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT: usize = lightning::ln::chan_utils::MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; +/// The upper bound weight of an anchor input. + +#[no_mangle] +pub static ANCHOR_INPUT_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::ANCHOR_INPUT_WITNESS_WEIGHT; +/// The upper bound weight of an HTLC timeout input from a commitment transaction with anchor +/// outputs. + +#[no_mangle] +pub static HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT; +/// The upper bound weight of an HTLC success input from a commitment transaction with anchor +/// outputs. + +#[no_mangle] +pub static HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; /// Gets the weight for an HTLC-Success transaction. #[no_mangle] -pub extern "C" fn htlc_success_tx_weight(mut opt_anchors: bool) -> u64 { - let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(opt_anchors); +pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { + let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(channel_type_features.get_native_ref()); ret } /// Gets the weight for an HTLC-Timeout transaction. #[no_mangle] -pub extern "C" fn htlc_timeout_tx_weight(mut opt_anchors: bool) -> u64 { - let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(opt_anchors); +pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { + let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(channel_type_features.get_native_ref()); ret } @@ -906,8 +920,8 @@ pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> c /// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc /// does not need to have its previous_output_index filled. #[no_mangle] -pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut opt_anchors: bool, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(htlc.get_native_ref(), opt_anchors, keys.get_native_ref()); +pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(htlc.get_native_ref(), channel_type_features.get_native_ref(), keys.get_native_ref()); ret.into_bytes().into() } @@ -927,18 +941,16 @@ pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::Pub /// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the /// commitment transaction). #[no_mangle] -pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut opt_anchors: bool, mut use_non_zero_fee_anchors: bool, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, htlc.get_native_ref(), opt_anchors, use_non_zero_fee_anchors, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); +pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { + let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, htlc.get_native_ref(), channel_type_features.get_native_ref(), &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); crate::c_types::Transaction::from_bitcoin(&ret) } /// Returns the witness required to satisfy and spend a HTLC input. -/// -/// Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::Signature, mut remote_sig: crate::c_types::Signature, mut preimage: crate::c_types::ThirtyTwoBytes, mut redeem_script: crate::c_types::u8slice, mut opt_anchors: bool) -> crate::c_types::Witness { - let mut local_preimage = if preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(preimage.data) }) }; - let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, &::bitcoin::blockdata::script::Script::from(Vec::from(redeem_script.to_slice())), opt_anchors); +pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::Signature, mut remote_sig: crate::c_types::Signature, mut preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::Witness { + let mut local_preimage = { /*preimage*/ let preimage_opt = preimage; if preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ preimage_opt.take() }.data) }})} }; + let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, &::bitcoin::blockdata::script::Script::from(Vec::from(redeem_script.to_slice())), channel_type_features.get_native_ref()); crate::c_types::Witness::from_bitcoin(&ret) } @@ -1094,54 +1106,32 @@ pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &m let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint = local_val; } -/// Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is -/// serialization backwards-compatible. +/// This channel's type, as negotiated during channel open. For old objects where this field +/// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_opt_anchors(this_ptr: &ChannelTransactionParameters) -> crate::c_types::derived::COption_NoneZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().opt_anchors; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; - local_inner_val +pub extern "C" fn ChannelTransactionParameters_get_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type_features; + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } -/// Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is -/// serialization backwards-compatible. +/// This channel's type, as negotiated during channel open. For old objects where this field +/// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_opt_anchors(this_ptr: &mut ChannelTransactionParameters, mut val: crate::c_types::derived::COption_NoneZ) { - let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opt_anchors = local_val; -} -/// Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) -/// It is intended merely for backwards compatibility with signers that need it. -/// There is no support for this feature in LDK channel negotiation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_opt_non_zero_fee_anchors(this_ptr: &ChannelTransactionParameters) -> crate::c_types::derived::COption_NoneZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().opt_non_zero_fee_anchors; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; - local_inner_val -} -/// Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) -/// It is intended merely for backwards compatibility with signers that need it. -/// There is no support for this feature in LDK channel negotiation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_opt_non_zero_fee_anchors(this_ptr: &mut ChannelTransactionParameters, mut val: crate::c_types::derived::COption_NoneZ) { - let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opt_non_zero_fee_anchors = local_val; +pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Constructs a new ChannelTransactionParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut opt_anchors_arg: crate::c_types::derived::COption_NoneZ, mut opt_non_zero_fee_anchors_arg: crate::c_types::derived::COption_NoneZ) -> ChannelTransactionParameters { +pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_features_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> ChannelTransactionParameters { let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; - let mut local_opt_anchors_arg = if opt_anchors_arg.is_some() { Some( { () /*opt_anchors_arg.take()*/ }) } else { None }; - let mut local_opt_non_zero_fee_anchors_arg = if opt_non_zero_fee_anchors_arg.is_some() { Some( { () /*opt_non_zero_fee_anchors_arg.take()*/ }) } else { None }; ChannelTransactionParameters { inner: ObjOps::heap_alloc(nativeChannelTransactionParameters { holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) }, holder_selected_contest_delay: holder_selected_contest_delay_arg, is_outbound_from_holder: is_outbound_from_holder_arg, counterparty_parameters: local_counterparty_parameters_arg, funding_outpoint: local_funding_outpoint_arg, - opt_anchors: local_opt_anchors_arg, - opt_non_zero_fee_anchors: local_opt_non_zero_fee_anchors_arg, + channel_type_features: *unsafe { Box::from_raw(channel_type_features_arg.take_inner()) }, }), is_owned: true } } impl Clone for ChannelTransactionParameters { @@ -1440,15 +1430,15 @@ pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &cr #[no_mangle] pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint(); - crate::c_types::bitcoin_to_C_outpoint(ret) + crate::c_types::bitcoin_to_C_outpoint(&ret) } /// Whether to use anchors for this channel #[must_use] #[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_opt_anchors(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret +pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } @@ -1719,7 +1709,7 @@ pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_commitment(this_a /// Signs the holder commitment transaction because we are about to broadcast it. #[must_use] #[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::Signature { +pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::Signature { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); crate::c_types::Signature::from_rust(&ret) } @@ -2200,9 +2190,9 @@ pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &crate::lightning: /// Should anchors be used. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret +pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// Get a signature for each HTLC which was included in the commitment transaction (ie for @@ -2213,7 +2203,7 @@ pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &crate::lig /// This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { +pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_htlc_sigs(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), channel_parameters.get_native_ref(), entropy_source, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index bcca9df..051661d 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -100,7 +100,7 @@ pub extern "C" fn FailureCode_incorrect_or_unknown_payment_details() -> FailureC FailureCode::IncorrectOrUnknownPaymentDetails} use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport; -pub(crate) type nativeChannelManager = nativeChannelManagerImport; +pub(crate) type nativeChannelManager = nativeChannelManagerImport; /// Manager which keeps track of a number of channels and sends messages to the appropriate /// channel, also tracking HTLC preimages and forwarding onion packets appropriately. @@ -994,7 +994,8 @@ pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut Chann /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us /// to use a limit as close as possible to the HTLC limit we can currently send. /// -/// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. #[no_mangle] pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat; @@ -1005,11 +1006,29 @@ pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &Ch /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us /// to use a limit as close as possible to the HTLC limit we can currently send. /// -/// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. #[no_mangle] pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val; } +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat; + *inner_val +} +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val; +} /// The available inbound capacity for the remote peer to send HTLCs to us. This does not /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not /// available for inclusion in new inbound HTLCs). @@ -1146,6 +1165,23 @@ pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val; } +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ { + let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val; +} /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) /// the peer is connected, and (c) the channel is not currently negotiating a shutdown. /// @@ -1226,7 +1262,7 @@ pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut v /// Constructs a new ChannelDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { +pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut next_outbound_htlc_minimum_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) }; let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; @@ -1237,6 +1273,7 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None }; let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None }; let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None }; + let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} }; let mut local_inbound_htlc_minimum_msat_arg = if inbound_htlc_minimum_msat_arg.is_some() { Some( { inbound_htlc_minimum_msat_arg.take() }) } else { None }; let mut local_inbound_htlc_maximum_msat_arg = if inbound_htlc_maximum_msat_arg.is_some() { Some( { inbound_htlc_maximum_msat_arg.take() }) } else { None }; let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) }; @@ -1255,12 +1292,14 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT balance_msat: balance_msat_arg, outbound_capacity_msat: outbound_capacity_msat_arg, next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg, + next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg, inbound_capacity_msat: inbound_capacity_msat_arg, confirmations_required: local_confirmations_required_arg, confirmations: local_confirmations_arg, force_close_spend_delay: local_force_close_spend_delay_arg, is_outbound: is_outbound_arg, is_channel_ready: is_channel_ready_arg, + channel_shutdown_state: local_channel_shutdown_state_arg, is_usable: is_usable_arg, is_public: is_public_arg, inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg, @@ -1315,6 +1354,105 @@ pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lig local_ret } +/// Further information on the details of the channel shutdown. +/// Upon channels being forced closed (i.e. commitment transaction confirmation detected +/// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or +/// the channel will be removed shortly. +/// Also note, that in normal operation, peers could disconnect at any of these states +/// and require peer re-connection before making progress onto other states +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum ChannelShutdownState { + /// Channel has not sent or received a shutdown message. + NotShuttingDown, + /// Local node has sent a shutdown message for this channel. + ShutdownInitiated, + /// Shutdown message exchanges have concluded and the channels are in the midst of + /// resolving all existing open HTLCs before closing can continue. + ResolvingHTLCs, + /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. + NegotiatingClosingFee, + /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about + /// to drop the channel. + ShutdownComplete, +} +use lightning::ln::channelmanager::ChannelShutdownState as ChannelShutdownStateImport; +pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport; + +impl ChannelShutdownState { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeChannelShutdownState) -> Self { + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self { + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } +} +/// Creates a copy of the ChannelShutdownState +#[no_mangle] +pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState { + ChannelShutdownState::NotShuttingDown} +#[no_mangle] +/// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState { + ChannelShutdownState::ShutdownInitiated} +#[no_mangle] +/// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState { + ChannelShutdownState::ResolvingHTLCs} +#[no_mangle] +/// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState { + ChannelShutdownState::NegotiatingClosingFee} +#[no_mangle] +/// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState { + ChannelShutdownState::ShutdownComplete} +/// Checks if two ChannelShutdownStates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. /// These include payments that have yet to find a successful path, or have unresolved HTLCs. #[derive(Clone)] @@ -1336,9 +1474,7 @@ pub enum RecentPaymentDetails { Fulfilled { /// Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`] /// made before LDK version 0.0.104. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_hash: crate::c_types::ThirtyTwoBytes, + payment_hash: crate::c_types::derived::COption_PaymentHashZ, }, /// After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly /// abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all @@ -1365,7 +1501,7 @@ impl RecentPaymentDetails { }, RecentPaymentDetails::Fulfilled {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) }; + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash_nonref, } @@ -1388,7 +1524,7 @@ impl RecentPaymentDetails { } }, RecentPaymentDetails::Fulfilled {mut payment_hash, } => { - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash, } @@ -1413,7 +1549,7 @@ impl RecentPaymentDetails { }, nativeRecentPaymentDetails::Fulfilled {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } }; + let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) }; RecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash_nonref, } @@ -1436,7 +1572,7 @@ impl RecentPaymentDetails { } }, nativeRecentPaymentDetails::Fulfilled {mut payment_hash, } => { - let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } }; + let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) }; RecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash, } @@ -1467,7 +1603,7 @@ pub extern "C" fn RecentPaymentDetails_pending(payment_hash: crate::c_types::Thi } #[no_mangle] /// Utility method to constructs a new Fulfilled-variant RecentPaymentDetails -pub extern "C" fn RecentPaymentDetails_fulfilled(payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails { +pub extern "C" fn RecentPaymentDetails_fulfilled(payment_hash: crate::c_types::derived::COption_PaymentHashZ) -> RecentPaymentDetails { RecentPaymentDetails::Fulfilled { payment_hash, } @@ -1485,7 +1621,7 @@ pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport; /// Route hints used in constructing invoices for [phantom node payents]. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[repr(C)] pub struct PhantomRouteHints { @@ -1601,6 +1737,8 @@ pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRo } /// Constructs a new `ChannelManager` to hold several channels and route between them. /// +/// The current time or latest block header time can be provided as the `current_timestamp`. +/// /// This is the main \"logic hub\" for all channel-related actions, and implements /// [`ChannelMessageHandler`]. /// @@ -1616,8 +1754,8 @@ pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRo /// [`params.best_block.block_hash`]: chain::BestBlock::block_hash #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut signer_provider: crate::lightning::chain::keysinterface::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters) -> crate::lightning::ln::channelmanager::ChannelManager { - let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, signer_provider, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }); +pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters, mut current_timestamp: u32) -> crate::lightning::ln::channelmanager::ChannelManager { + let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, signer_provider, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }, current_timestamp); crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1640,6 +1778,10 @@ pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &cr /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`]. +/// /// Note that we do not check if you are currently connected to the given peer. If no /// connection is available, the outbound `open_channel` message may fail to send, resulting in /// the channel eventually being silently forgotten (dropped on reload). @@ -1728,6 +1870,11 @@ pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightnin /// /// May generate a [`SendShutdown`] message event on success, which should be relayed. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the +/// channel. +/// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal @@ -1754,16 +1901,30 @@ pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln:: /// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which /// will appear on a force-closure transaction, whichever is lower). /// +/// The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction. +/// Will fail if a shutdown script has already been set for this channel by +/// ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must +/// also be compatible with our and the counterparty's features. +/// /// May generate a [`SendShutdown`] message event on success, which should be relayed. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the +/// channel. +/// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown +/// +/// Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_close_channel_with_target_feerate(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: u32) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_target_feerate(unsafe { &*channel_id}, &counterparty_node_id.into_rust(), target_feerate_sats_per_1000_weight); +pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_target_feerate_sats_per_1000_weight = if target_feerate_sats_per_1000_weight.is_some() { Some( { target_feerate_sats_per_1000_weight.take() }) } else { None }; + let mut local_shutdown_script = if shutdown_script.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(shutdown_script.take_inner()) } }) }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(unsafe { &*channel_id}, &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -1854,6 +2015,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a /// different route unless you intend to pay twice! /// +/// [`RouteHop`]: crate::routing::router::RouteHop /// [`Event::PaymentSent`]: events::Event::PaymentSent /// [`Event::PaymentFailed`]: events::Event::PaymentFailed /// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs @@ -1867,7 +2029,7 @@ pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::light local_ret } -/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on +/// Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on /// `route_params` and retry failed payment paths based on `retry_strategy`. #[must_use] #[no_mangle] @@ -1910,15 +2072,11 @@ pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See /// [`send_payment`] for more information about the risks of duplicate preimage usage. /// -/// Note that `route` must have exactly one path. -/// /// [`send_payment`]: Self::send_payment -/// -/// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; +pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret @@ -1931,12 +2089,10 @@ pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::ligh /// payments. /// /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend -/// -/// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; +pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret @@ -1991,6 +2147,37 @@ pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate: local_ret } +/// Atomically applies partial updates to the [`ChannelConfig`] of the given channels. +/// +/// Once the updates are applied, each eligible channel (advertised with a known short channel +/// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], +/// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated +/// containing the new [`ChannelUpdate`] message which should be broadcast to the network. +/// +/// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect +/// `counterparty_node_id` is provided. +/// +/// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value +/// below [`MIN_CLTV_EXPIRY_DELTA`]. +/// +/// If an error is returned, none of the updates should be considered applied. +/// +/// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths +/// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat +/// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta +/// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate +/// [`ChannelUpdate`]: msgs::ChannelUpdate +/// [`ChannelUnavailable`]: APIError::ChannelUnavailable +/// [`APIMisuseError`]: APIError::APIMisuseError +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { item.data }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_partial_channel_config(&counterparty_node_id.into_rust(), &local_channel_ids.iter().map(|a| *a).collect::>()[..], config_update.get_native_ref()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + /// Atomically updates the [`ChannelConfig`] for the given channels. /// /// Once the updates are applied, each eligible channel (advertised with a known short channel @@ -2035,13 +2222,16 @@ pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightni /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. /// /// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop -/// you from forwarding more than you received. +/// you from forwarding more than you received. See +/// [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount +/// than expected. /// /// Errors if the event was not handled in time, in which case the HTLC was automatically failed /// backwards. /// /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: *const [u8; 32], mut next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { @@ -2084,6 +2274,7 @@ pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate: /// * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs /// with the current [`ChannelConfig`]. /// * Removing peers which have disconnected but and no longer have any channels. +/// * Force-closing and removing channels which have not completed establishment in a timely manner. /// /// Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate /// estimate fetches. @@ -2246,24 +2437,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &crate::lightn local_ret } -/// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share -/// serialized state with LDK node(s) running 0.0.103 and earlier. -/// -/// May panic if `invoice_expiry_delta_secs` is greater than one year. -/// -/// # Note -/// This method is deprecated and will be removed soon. -/// -/// [`create_inbound_payment`]: Self::create_inbound_payment -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_create_inbound_payment_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_legacy(local_min_value_msat, invoice_expiry_delta_secs); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is /// stored external to LDK. /// @@ -2320,24 +2493,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &crat local_ret } -/// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share -/// serialized state with LDK node(s) running 0.0.103 and earlier. -/// -/// May panic if `invoice_expiry_delta_secs` is greater than one year. -/// -/// # Note -/// This method is deprecated and will be removed soon. -/// -/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_create_inbound_payment_for_hash_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_PaymentSecretAPIErrorZ { - let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash_legacy(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - /// Gets an LDK-generated payment preimage from a payment hash and payment secret that were /// previously returned from [`create_inbound_payment`]. /// @@ -2353,7 +2508,7 @@ pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &crate::lightnin /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids /// are used when constructing the phantom invoice's route hints. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 { @@ -2363,7 +2518,7 @@ pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::l /// Gets route hints for use in receiving [phantom node payments]. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints { @@ -2515,9 +2670,9 @@ extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] -extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } @@ -2596,12 +2751,23 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel, + handle_open_channel_v2: ChannelManager_ChannelMessageHandler_handle_open_channel_v2, handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel, + handle_accept_channel_v2: ChannelManager_ChannelMessageHandler_handle_accept_channel_v2, handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created, handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed, handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready, handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed, + handle_tx_add_input: ChannelManager_ChannelMessageHandler_handle_tx_add_input, + handle_tx_add_output: ChannelManager_ChannelMessageHandler_handle_tx_add_output, + handle_tx_remove_input: ChannelManager_ChannelMessageHandler_handle_tx_remove_input, + handle_tx_remove_output: ChannelManager_ChannelMessageHandler_handle_tx_remove_output, + handle_tx_complete: ChannelManager_ChannelMessageHandler_handle_tx_complete, + handle_tx_signatures: ChannelManager_ChannelMessageHandler_handle_tx_signatures, + handle_tx_init_rbf: ChannelManager_ChannelMessageHandler_handle_tx_init_rbf, + handle_tx_ack_rbf: ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf, + handle_tx_abort: ChannelManager_ChannelMessageHandler_handle_tx_abort, handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc, handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc, handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc, @@ -2617,6 +2783,7 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana handle_error: ChannelManager_ChannelMessageHandler_handle_error, provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features, provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features, + get_genesis_hashes: ChannelManager_ChannelMessageHandler_get_genesis_hashes, MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -2628,9 +2795,15 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { + >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { + >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -2646,6 +2819,33 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *co extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { + >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { + >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { + >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { + >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { + >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { + >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { + >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { + >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { + >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -2698,12 +2898,18 @@ extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_a let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +#[must_use] +extern "C" fn ChannelManager_ChannelMessageHandler_get_genesis_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut ret = >::get_genesis_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) }; + local_ret +} /// Fetches the set of [`InitFeatures`] flags which are provided by or required by /// [`ChannelManager`]. #[no_mangle] -pub extern "C" fn provided_init_features(_config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures { - let mut ret = lightning::ln::channelmanager::provided_init_features(_config.get_native_ref()); +pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures { + let mut ret = lightning::ln::channelmanager::provided_init_features(config.get_native_ref()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -2780,9 +2986,21 @@ pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanage pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) } +#[no_mangle] +/// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read +pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channelmanager::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write +pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; -pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::EntropySource, crate::lightning::chain::keysinterface::NodeSigner, crate::lightning::chain::keysinterface::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>; +pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>; /// Arguments for the creation of a ChannelManager that are not deserialized. /// @@ -2864,31 +3082,31 @@ impl ChannelManagerReadArgs { } /// A cryptographically secure source of entropy. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::EntropySource { +pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::EntropySource { let mut inner_val = &mut this_ptr.get_native_mut_ref().entropy_source; inner_val } /// A cryptographically secure source of entropy. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::EntropySource) { +pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::EntropySource) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.entropy_source = val; } /// A signer that is able to perform node-scoped cryptographic operations. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::NodeSigner { +pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::NodeSigner { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signer; inner_val } /// A signer that is able to perform node-scoped cryptographic operations. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::NodeSigner) { +pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::NodeSigner) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signer = val; } /// The keys provider which will give us relevant keys. Some keys will be loaded during /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel /// signing data. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::SignerProvider { +pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::SignerProvider { let mut inner_val = &mut this_ptr.get_native_mut_ref().signer_provider; inner_val } @@ -2896,7 +3114,7 @@ pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelM /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel /// signing data. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::SignerProvider) { +pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::SignerProvider) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signer_provider = val; } /// The fee_estimator for use in the ChannelManager in the future. @@ -2996,7 +3214,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut Chann /// populate a HashMap directly from C. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut signer_provider: crate::lightning::chain::keysinterface::SignerProvider, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> crate::lightning::ln::channelmanager::ChannelManagerReadArgs { +pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> crate::lightning::ln::channelmanager::ChannelManagerReadArgs { let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { item.get_native_mut_ref() }); }; let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster, router, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors); crate::lightning::ln::channelmanager::ChannelManagerReadArgs { inner: ObjOps::heap_alloc(ret), is_owned: true } @@ -3006,7 +3224,7 @@ pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightnin /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index 7f8c8e8..cb7453b 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -63,6 +63,12 @@ //! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more //! information). //! +//! LDK knows about the following features, but does not support them: +//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be +//! vulnerable (see this +//! [mailing list post](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html) +//! for more information). +//! //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md //! [messages]: crate::ln::msgs @@ -314,20 +320,20 @@ pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate:: /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_variable_length_onion_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_variable_length_onion_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); ret } @@ -351,7 +357,7 @@ pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate:: /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); ret } @@ -482,20 +488,20 @@ pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightni /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_secret_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_secret_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); ret } @@ -519,7 +525,7 @@ pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightni /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); ret } @@ -566,20 +572,20 @@ pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning::l /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_basic_mpp_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_basic_mpp_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); ret } @@ -623,7 +629,7 @@ pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning::l /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); ret } @@ -692,6 +698,90 @@ pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning::ln::f ret } +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + /// Set this feature as optional. #[no_mangle] pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { @@ -1030,20 +1120,20 @@ pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::li /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_metadata(); ret } @@ -1051,7 +1141,7 @@ pub extern "C" fn InvoiceFeatures_supports_payment_metadata(this_arg: &crate::li /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_metadata(); ret } @@ -1196,11 +1286,11 @@ pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) - if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Checks if two InvoiceFeaturess contain equal inner contents. +/// Checks if two Bolt11InvoiceFeaturess 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. #[no_mangle] -pub extern "C" fn InvoiceFeatures_eq(a: &InvoiceFeatures, b: &InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_eq(a: &Bolt11InvoiceFeatures, b: &Bolt11InvoiceFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -1307,10 +1397,10 @@ pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { orig.clone() } -impl Clone for InvoiceFeatures { +impl Clone for Bolt11InvoiceFeatures { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1318,12 +1408,12 @@ impl Clone for InvoiceFeatures { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the InvoiceFeatures -pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures { +/// Creates a copy of the Bolt11InvoiceFeatures +pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { orig.clone() } impl Clone for OfferFeatures { @@ -1575,18 +1665,18 @@ impl ChannelFeatures { } } -use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; -pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; +use lightning::ln::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; +pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; /// Features used within an invoice. #[must_use] #[repr(C)] -pub struct InvoiceFeatures { +pub struct Bolt11InvoiceFeatures { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoiceFeatures, + pub inner: *mut nativeBolt11InvoiceFeatures, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1594,31 +1684,31 @@ pub struct InvoiceFeatures { pub is_owned: bool, } -impl Drop for InvoiceFeatures { +impl Drop for Bolt11InvoiceFeatures { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } +pub extern "C" fn Bolt11InvoiceFeatures_free(this_obj: Bolt11InvoiceFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceFeatures) }; +pub(crate) extern "C" fn Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; } #[allow(unused)] -impl InvoiceFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures { +impl Bolt11InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceFeatures { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceFeatures { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceFeatures { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -1897,6 +1987,14 @@ pub extern "C" fn InitFeatures_empty() -> crate::lightning::ln::features::InitFe crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InitFeatures, other: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1906,6 +2004,36 @@ pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1914,6 +2042,14 @@ pub extern "C" fn NodeFeatures_empty() -> crate::lightning::ln::features::NodeFe crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::NodeFeatures, other: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1923,6 +2059,36 @@ pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1931,6 +2097,14 @@ pub extern "C" fn ChannelFeatures_empty() -> crate::lightning::ln::features::Cha crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelFeatures, other: &crate::lightning::ln::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1940,23 +2114,91 @@ pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightn ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_empty() -> crate::lightning::ln::features::InvoiceFeatures { - let mut ret = lightning::ln::features::InvoiceFeatures::empty(); - crate::lightning::ln::features::InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +pub extern "C" fn Bolt11InvoiceFeatures_empty() -> crate::lightning::ln::features::Bolt11InvoiceFeatures { + let mut ret = lightning::ln::features::Bolt11InvoiceFeatures::empty(); + crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures, other: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret } /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1965,6 +2207,14 @@ pub extern "C" fn OfferFeatures_empty() -> crate::lightning::ln::features::Offer crate::lightning::ln::features::OfferFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::OfferFeatures, other: &crate::lightning::ln::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1974,6 +2224,36 @@ pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightnin ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1982,6 +2262,14 @@ pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning::ln::featur crate::lightning::ln::features::InvoiceRequestFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InvoiceRequestFeatures, other: &crate::lightning::ln::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1991,6 +2279,36 @@ pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate: ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1999,6 +2317,14 @@ pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning::ln::feature crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures, other: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2008,6 +2334,36 @@ pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate:: ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -2016,6 +2372,14 @@ pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning::ln::features:: crate::lightning::ln::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::BlindedHopFeatures, other: &crate::lightning::ln::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2025,6 +2389,36 @@ pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lig ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -2033,6 +2427,14 @@ pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning::ln::features: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures, other: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2042,6 +2444,36 @@ pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::li ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + #[no_mangle] /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read pub extern "C" fn InitFeatures_write(obj: &crate::lightning::ln::features::InitFeatures) -> crate::c_types::derived::CVec_u8Z { @@ -2091,19 +2523,35 @@ pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_ty local_res } #[no_mangle] -/// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read -pub extern "C" fn InvoiceFeatures_write(obj: &crate::lightning::ln::features::InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read +pub extern "C" fn Bolt11InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Bolt11InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt11InvoiceFeatures) }) +} +#[no_mangle] +/// Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write +pub extern "C" fn Bolt11InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read +pub extern "C" fn Bolt12InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] -pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) }) +pub(crate) extern "C" fn Bolt12InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12InvoiceFeatures) }) } #[no_mangle] -/// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write -pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; +/// Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write +pub extern "C" fn Bolt12InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs index 6878fa2..4a4d1dd 100644 --- a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs @@ -23,7 +23,7 @@ pub(crate) type nativeExpandedKey = nativeExpandedKeyImport; /// A set of keys that were HKDF-expanded from an initial call to /// [`NodeSigner::get_inbound_payment_key_material`]. /// -/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material +/// [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material #[must_use] #[repr(C)] pub struct ExpandedKey { @@ -76,7 +76,7 @@ impl ExpandedKey { #[must_use] #[no_mangle] pub extern "C" fn ExpandedKey_new(key_material: *const [u8; 32]) -> crate::lightning::ln::inbound_payment::ExpandedKey { - let mut ret = lightning::ln::inbound_payment::ExpandedKey::new(&::lightning::chain::keysinterface::KeyMaterial( unsafe { *key_material })); + let mut ret = lightning::ln::inbound_payment::ExpandedKey::new(&::lightning::sign::KeyMaterial( unsafe { *key_material })); crate::lightning::ln::inbound_payment::ExpandedKey { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -93,13 +93,13 @@ pub extern "C" fn ExpandedKey_new(key_material: *const [u8; 32]) -> crate::light /// Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable /// on versions of LDK prior to 0.0.114. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager -/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material +/// [phantom node payments]: crate::sign::PhantomKeysManager +/// [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material #[no_mangle] -pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, entropy_source: &crate::lightning::chain::keysinterface::EntropySource, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, entropy_source: &crate::lightning::sign::EntropySource, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); + let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -113,7 +113,7 @@ pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedK /// Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable /// on versions of LDK prior to 0.0.114. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[no_mangle] pub extern "C" fn create_from_hash(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut invoice_expiry_delta_secs: u32, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_PaymentSecretNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 02b5eba..d3e4c4b 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -236,6 +236,25 @@ pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::fe pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Indicates chains the sender is interested in. +/// +/// If there are no common chains, the connection will be closed. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut inner_val = this_ptr.get_native_mut_ref().networks.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) }; + local_inner_val +} +/// Indicates chains the sender is interested in. +/// +/// If there are no common chains, the connection will be closed. +#[no_mangle] +pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ChainHashZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_val_0 }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val; +} /// The receipient's network address. /// /// This adds the option to report a remote IP address back to a connecting peer using the init @@ -262,10 +281,12 @@ pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: /// Constructs a new Init given each field #[must_use] #[no_mangle] -pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init { +pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ChainHashZZ, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init { + let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_networks_arg_0 }})} }; let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} }; Init { inner: ObjOps::heap_alloc(nativeInit { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + networks: local_networks_arg, remote_network_address: local_remote_network_address_arg, }), is_owned: true } } @@ -773,6 +794,8 @@ pub(crate) type nativeOpenChannel = nativeOpenChannelImport; /// An [`open_channel`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message #[must_use] #[repr(C)] @@ -1022,6 +1045,19 @@ pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } +/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} /// The channel type that this channel will represent /// /// If this is `None`, we derive the channel type from the intersection of our @@ -1045,6 +1081,35 @@ pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut v let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; } +/// Constructs a new OpenChannel given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + temporary_channel_id: temporary_channel_id_arg.data, + funding_satoshis: funding_satoshis_arg, + push_msat: push_msat_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + channel_reserve_satoshis: channel_reserve_satoshis_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + feerate_per_kw: feerate_per_kw_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_point: payment_point_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + channel_flags: channel_flags_arg, + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + }), is_owned: true } +} impl Clone for OpenChannel { fn clone(&self) -> Self { Self { @@ -1074,11 +1139,391 @@ pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } +use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import; +pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import; + +/// An open_channel2 message to be sent by or received from the channel initiator. +/// +/// Used in V2 channel establishment +/// +#[must_use] +#[repr(C)] +pub struct OpenChannelV2 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOpenChannelV2, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OpenChannelV2 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) }; +} +#[allow(unused)] +impl OpenChannelV2 { + pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain where the channel is to be opened +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; + inner_val.as_inner() +} +/// The genesis hash of the blockchain where the channel is to be opened +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; + inner_val +} +/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data; +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val; +} +/// The feerate for the commitment transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate for the commitment transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; +} +/// Part of the channel value contributed by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; + *inner_val +} +/// Part of the channel value contributed by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; +} +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; + *inner_val +} +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; +} +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; + *inner_val +} +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; +} +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The maximum number of inbound HTLCs towards channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; + *inner_val +} +/// The maximum number of inbound HTLCs towards channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; + *inner_val +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +} +/// The channel initiator's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The channel initiator's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); +} +/// A payment key to channel initiator for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A payment key to channel initiator for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); +} +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +} +/// Used to derive an HTLC payment key to channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive an HTLC payment key to channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +} +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); +} +/// Channel flags +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; + *inner_val +} +/// Channel flags +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; +} +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} +/// Constructs a new OpenChannelV2 given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + temporary_channel_id: temporary_channel_id_arg.data, + funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg, + commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, + funding_satoshis: funding_satoshis_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + locktime: locktime_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + second_per_commitment_point: second_per_commitment_point_arg.into_rust(), + channel_flags: channel_flags_arg, + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + require_confirmed_inputs: local_require_confirmed_inputs_arg, + }), is_owned: true } +} +impl Clone for OpenChannelV2 { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OpenChannelV2 +pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 { + orig.clone() +} +/// Checks if two OpenChannelV2s 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. +#[no_mangle] +pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport; pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport; /// An [`accept_channel`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message #[must_use] #[repr(C)] @@ -1280,6 +1725,19 @@ pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &Accept pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); } +/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} /// The channel type that this channel will represent. /// /// If this is `None`, we derive the channel type from the intersection of @@ -1305,6 +1763,31 @@ pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, m let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; } +/// Constructs a new AcceptChannel given each field +#[must_use] +#[no_mangle] +pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel { + temporary_channel_id: temporary_channel_id_arg.data, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + channel_reserve_satoshis: channel_reserve_satoshis_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + minimum_depth: minimum_depth_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_point: payment_point_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + }), is_owned: true } +} impl Clone for AcceptChannel { fn clone(&self) -> Self { Self { @@ -1334,12 +1817,348 @@ pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport; -pub(crate) type nativeFundingCreated = nativeFundingCreatedImport; +use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import; +pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import; -/// A [`funding_created`] message to be sent to or received from a peer. +/// An accept_channel2 message to be sent by or received from the channel accepter. /// -/// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message +/// Used in V2 channel establishment +/// +#[must_use] +#[repr(C)] +pub struct AcceptChannelV2 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeAcceptChannelV2, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for AcceptChannelV2 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) }; +} +#[allow(unused)] +impl AcceptChannelV2 { + pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; + inner_val +} +/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data; +} +/// Part of the channel value contributed by the channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; + *inner_val +} +/// Part of the channel value contributed by the channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; +} +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; + *inner_val +} +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; +} +/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; + *inner_val +} +/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; +} +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// Minimum depth of the funding transaction before the channel is considered open +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth; + *inner_val +} +/// Minimum depth of the funding transaction before the channel is considered open +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val; +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The maximum number of inbound HTLCs towards channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; + *inner_val +} +/// The maximum number of inbound HTLCs towards channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +} +/// The channel acceptor's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The channel acceptor's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); +} +/// A payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); +} +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +} +/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} +/// Constructs a new AcceptChannelV2 given each field +#[must_use] +#[no_mangle] +pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 { + temporary_channel_id: temporary_channel_id_arg.data, + funding_satoshis: funding_satoshis_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + minimum_depth: minimum_depth_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + second_per_commitment_point: second_per_commitment_point_arg.into_rust(), + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + require_confirmed_inputs: local_require_confirmed_inputs_arg, + }), is_owned: true } +} +impl Clone for AcceptChannelV2 { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the AcceptChannelV2 +pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 { + orig.clone() +} +/// Checks if two AcceptChannelV2s 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. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport; +pub(crate) type nativeFundingCreated = nativeFundingCreatedImport; + +/// A [`funding_created`] message to be sent to or received from a peer. +/// +/// Used in V1 channel establishment +/// +/// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message #[must_use] #[repr(C)] pub struct FundingCreated { @@ -1475,6 +2294,8 @@ pub(crate) type nativeFundingSigned = nativeFundingSignedImport; /// A [`funding_signed`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message #[must_use] #[repr(C)] @@ -1682,14 +2503,1127 @@ pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwo let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None }; ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady { channel_id: channel_id_arg.data, - next_per_commitment_point: next_per_commitment_point_arg.into_rust(), - short_channel_id_alias: local_short_channel_id_alias_arg, + next_per_commitment_point: next_per_commitment_point_arg.into_rust(), + short_channel_id_alias: local_short_channel_id_alias_arg, + }), is_owned: true } +} +impl Clone for ChannelReady { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelReady +pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady { + orig.clone() +} +/// Checks if two ChannelReadys 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. +#[no_mangle] +pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport; +pub(crate) type nativeTxAddInput = nativeTxAddInputImport; + +/// A tx_add_input message for adding an input during interactive transaction construction +/// +#[must_use] +#[repr(C)] +pub struct TxAddInput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAddInput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAddInput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) }; +} +#[allow(unused)] +impl TxAddInput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// A randomly chosen unique identifier for this input, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// A randomly chosen unique identifier for this input, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Serialized transaction that contains the output this input spends to verify that it is non +/// malleable. +#[no_mangle] +pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited { + let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx; + crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false } +} +/// Serialized transaction that contains the output this input spends to verify that it is non +/// malleable. +#[no_mangle] +pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The index of the output being spent +#[no_mangle] +pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out; + *inner_val +} +/// The index of the output being spent +#[no_mangle] +pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val; +} +/// The sequence number of this input +#[no_mangle] +pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence; + *inner_val +} +/// The sequence number of this input +#[no_mangle] +pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val; +} +/// Constructs a new TxAddInput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput { + TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) }, + prevtx_out: prevtx_out_arg, + sequence: sequence_arg, + }), is_owned: true } +} +impl Clone for TxAddInput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAddInput +pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput { + orig.clone() +} +/// Checks if two TxAddInputs 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. +#[no_mangle] +pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport; +pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport; + +/// A tx_add_output message for adding an output during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxAddOutput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAddOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAddOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) }; +} +#[allow(unused)] +impl TxAddOutput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// A randomly chosen unique identifier for this output, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// A randomly chosen unique identifier for this output, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// The satoshi value of the output +#[no_mangle] +pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().sats; + *inner_val +} +/// The satoshi value of the output +#[no_mangle] +pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val; +} +/// The scriptPubKey for the output +#[no_mangle] +pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice { + let mut inner_val = &mut this_ptr.get_native_mut_ref().script; + crate::c_types::u8slice::from_slice(&inner_val[..]) +} +/// The scriptPubKey for the output +#[no_mangle] +pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust()); +} +/// Constructs a new TxAddOutput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput { + TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + sats: sats_arg, + script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()), + }), is_owned: true } +} +impl Clone for TxAddOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAddOutput +pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput { + orig.clone() +} +/// Checks if two TxAddOutputs 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. +#[no_mangle] +pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport; +pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport; + +/// A tx_remove_input message for removing an input during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxRemoveInput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxRemoveInput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxRemoveInput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) }; +} +#[allow(unused)] +impl TxRemoveInput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The serial ID of the input to be removed +#[no_mangle] +pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// The serial ID of the input to be removed +#[no_mangle] +pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Constructs a new TxRemoveInput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput { + TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + }), is_owned: true } +} +impl Clone for TxRemoveInput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxRemoveInput +pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput { + orig.clone() +} +/// Checks if two TxRemoveInputs 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. +#[no_mangle] +pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport; +pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport; + +/// A tx_remove_output message for removing an output during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxRemoveOutput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxRemoveOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxRemoveOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) }; +} +#[allow(unused)] +impl TxRemoveOutput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The serial ID of the output to be removed +#[no_mangle] +pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// The serial ID of the output to be removed +#[no_mangle] +pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Constructs a new TxRemoveOutput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput { + TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + }), is_owned: true } +} +impl Clone for TxRemoveOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxRemoveOutput +pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput { + orig.clone() +} +/// Checks if two TxRemoveOutputs 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. +#[no_mangle] +pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxComplete as nativeTxCompleteImport; +pub(crate) type nativeTxComplete = nativeTxCompleteImport; + +/// A tx_complete message signalling the conclusion of a peer's transaction contributions during +/// interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxComplete { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxComplete, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxComplete { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxComplete_free(this_obj: TxComplete) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) }; +} +#[allow(unused)] +impl TxComplete { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// Constructs a new TxComplete given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete { + TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete { + channel_id: channel_id_arg.data, + }), is_owned: true } +} +impl Clone for TxComplete { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxComplete +pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete { + orig.clone() +} +/// Checks if two TxCompletes 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. +#[no_mangle] +pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport; +pub(crate) type nativeTxSignatures = nativeTxSignaturesImport; + +/// A tx_signatures message containing the sender's signatures for a transaction constructed with +/// interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxSignatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxSignatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxSignatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) }; +} +#[allow(unused)] +impl TxSignatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The TXID +#[no_mangle] +pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash; + inner_val.as_inner() +} +/// The TXID +#[no_mangle] +pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} +/// The list of witnesses +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ { + let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); }; + local_inner_val.into() +} +/// The list of witnesses +#[no_mangle] +pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val; +} +/// Constructs a new TxSignatures given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures { + let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); }; + TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures { + channel_id: channel_id_arg.data, + tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(), + witnesses: local_witnesses_arg, + }), is_owned: true } +} +impl Clone for TxSignatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxSignatures +pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures { + orig.clone() +} +/// Checks if two TxSignaturess 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. +#[no_mangle] +pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport; +pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport; + +/// A tx_init_rbf message which initiates a replacement of the transaction after it's been +/// completed. +/// +#[must_use] +#[repr(C)] +pub struct TxInitRbf { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxInitRbf, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxInitRbf { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) }; +} +#[allow(unused)] +impl TxInitRbf { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The locktime of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; + *inner_val +} +/// The locktime of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +} +/// The feerate of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val; +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val; +} +/// Constructs a new TxInitRbf given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf { + let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; + TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf { + channel_id: channel_id_arg.data, + locktime: locktime_arg, + feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg, + funding_output_contribution: local_funding_output_contribution_arg, + }), is_owned: true } +} +impl Clone for TxInitRbf { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxInitRbf +pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf { + orig.clone() +} +/// Checks if two TxInitRbfs 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. +#[no_mangle] +pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport; +pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport; + +/// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been +/// completed. +/// +#[must_use] +#[repr(C)] +pub struct TxAckRbf { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAckRbf, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAckRbf { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) }; +} +#[allow(unused)] +impl TxAckRbf { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val; +} +/// Constructs a new TxAckRbf given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf { + let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; + TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf { + channel_id: channel_id_arg.data, + funding_output_contribution: local_funding_output_contribution_arg, + }), is_owned: true } +} +impl Clone for TxAckRbf { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAckRbf +pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf { + orig.clone() +} +/// Checks if two TxAckRbfs 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. +#[no_mangle] +pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAbort as nativeTxAbortImport; +pub(crate) type nativeTxAbort = nativeTxAbortImport; + +/// A tx_abort message which signals the cancellation of an in-progress transaction negotiation. +/// +#[must_use] +#[repr(C)] +pub struct TxAbort { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAbort, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAbort { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAbort_free(this_obj: TxAbort) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) }; +} +#[allow(unused)] +impl TxAbort { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// Message data +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z { + let mut inner_val = this_ptr.get_native_mut_ref().data.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// Message data +#[no_mangle] +pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val; +} +/// Constructs a new TxAbort given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort { + let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); }; + TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort { + channel_id: channel_id_arg.data, + data: local_data_arg, }), is_owned: true } } -impl Clone for ChannelReady { +impl Clone for TxAbort { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1697,19 +3631,19 @@ impl Clone for ChannelReady { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void +pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ChannelReady -pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady { +/// Creates a copy of the TxAbort +pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort { orig.clone() } -/// Checks if two ChannelReadys contain equal inner contents. +/// Checks if two TxAborts 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. #[no_mangle] -pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { +pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -2200,6 +4134,25 @@ pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val; } +/// The extra fee skimmed by the sender of this message. See +/// [`ChannelConfig::accept_underpaying_htlcs`]. +/// +/// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs +#[no_mangle] +pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The extra fee skimmed by the sender of this message. See +/// [`ChannelConfig::accept_underpaying_htlcs`]. +/// +/// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs +#[no_mangle] +pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val; +} impl Clone for UpdateAddHTLC { fn clone(&self) -> Self { Self { @@ -3026,122 +4979,6 @@ pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport; -pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport; - -/// Proof that the sender knows the per-commitment secret of the previous commitment transaction. -/// -/// This is used to convince the recipient that the channel is at a certain commitment -/// number even if they lost that data due to a local failure. Of course, the peer may lie -/// and even later commitments may have been revoked. -#[must_use] -#[repr(C)] -pub struct DataLossProtect { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeDataLossProtect, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DataLossProtect { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDataLossProtect) }; -} -#[allow(unused)] -impl DataLossProtect { - pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Proof that the sender knows the per-commitment secret of a specific commitment transaction -/// belonging to the recipient -#[no_mangle] -pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret; - inner_val -} -/// Proof that the sender knows the per-commitment secret of a specific commitment transaction -/// belonging to the recipient -#[no_mangle] -pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data; -} -/// The sender's per-commitment point for their current commitment transaction -#[no_mangle] -pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The sender's per-commitment point for their current commitment transaction -#[no_mangle] -pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust(); -} -/// Constructs a new DataLossProtect given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect { - DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect { - your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data, - my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(), - }), is_owned: true } -} -impl Clone for DataLossProtect { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DataLossProtect -pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect { - orig.clone() -} -/// Checks if two DataLossProtects 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. -#[no_mangle] -pub extern "C" fn DataLossProtect_eq(a: &DataLossProtect, b: &DataLossProtect) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} - use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport; pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport; @@ -3227,6 +5064,57 @@ pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val; } +/// Proof that the sender knows the per-commitment secret of a specific commitment transaction +/// belonging to the recipient +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret; + inner_val +} +/// Proof that the sender knows the per-commitment secret of a specific commitment transaction +/// belonging to the recipient +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data; +} +/// The sender's per-commitment point for their current commitment transaction +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The sender's per-commitment point for their current commitment transaction +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust(); +} +/// The next funding transaction ID +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_TxidZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxidZ::None } else { crate::c_types::derived::COption_TxidZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) }; + local_inner_val +} +/// The next funding transaction ID +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_TxidZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val; +} +/// Constructs a new ChannelReestablish given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_TxidZ) -> ChannelReestablish { + let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} }; + ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish { + channel_id: channel_id_arg.data, + next_local_commitment_number: next_local_commitment_number_arg, + next_remote_commitment_number: next_remote_commitment_number_arg, + your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data, + my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(), + next_funding_txid: local_next_funding_txid_arg, + }), is_owned: true } +} impl Clone for ChannelReestablish { fn clone(&self) -> Self { Self { @@ -5400,6 +7288,11 @@ pub enum ErrorAction { /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None msg: crate::lightning::ln::msgs::ErrorMessage, }, + /// The peer did something incorrect. Tell them without closing any channels and disconnect them. + DisconnectPeerWithWarning { + /// A warning message which we should make an effort to send before we disconnect. + msg: crate::lightning::ln::msgs::WarningMessage, + }, /// The peer did something harmless that we weren't able to process, just log and ignore IgnoreError, /// The peer did something harmless that we weren't able to meaningfully process. @@ -5439,6 +7332,12 @@ impl ErrorAction { msg: local_msg_nonref, } }, + ErrorAction::DisconnectPeerWithWarning {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + nativeErrorAction::DisconnectPeerWithWarning { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, ErrorAction::IgnoreAndLog (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -5472,6 +7371,11 @@ impl ErrorAction { msg: local_msg, } }, + ErrorAction::DisconnectPeerWithWarning {mut msg, } => { + nativeErrorAction::DisconnectPeerWithWarning { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, ErrorAction::IgnoreAndLog (mut a, ) => { nativeErrorAction::IgnoreAndLog ( @@ -5502,6 +7406,12 @@ impl ErrorAction { msg: local_msg_nonref, } }, + nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + ErrorAction::DisconnectPeerWithWarning { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, nativeErrorAction::IgnoreAndLog (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -5535,6 +7445,11 @@ impl ErrorAction { msg: local_msg, } }, + nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => { + ErrorAction::DisconnectPeerWithWarning { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, nativeErrorAction::IgnoreAndLog (mut a, ) => { ErrorAction::IgnoreAndLog ( @@ -5572,6 +7487,13 @@ pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::E } } #[no_mangle] +/// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction +pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction { + ErrorAction::DisconnectPeerWithWarning { + msg, + } +} +#[no_mangle] /// Utility method to constructs a new IgnoreError-variant ErrorAction pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction { ErrorAction::IgnoreError} @@ -5889,8 +7811,12 @@ pub struct ChannelMessageHandler { pub this_arg: *mut c_void, /// Handle an incoming `open_channel` message from the given peer. pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel), + /// Handle an incoming `open_channel2` message from the given peer. + pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2), /// Handle an incoming `accept_channel` message from the given peer. pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel), + /// Handle an incoming `accept_channel2` message from the given peer. + pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2), /// Handle an incoming `funding_created` message from the given peer. pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated), /// Handle an incoming `funding_signed` message from the given peer. @@ -5901,6 +7827,24 @@ pub struct ChannelMessageHandler { pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown), /// Handle an incoming `closing_signed` message from the given peer. pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned), + /// Handle an incoming `tx_add_input message` from the given peer. + pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput), + /// Handle an incoming `tx_add_output` message from the given peer. + pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput), + /// Handle an incoming `tx_remove_input` message from the given peer. + pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput), + /// Handle an incoming `tx_remove_output` message from the given peer. + pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput), + /// Handle an incoming `tx_complete message` from the given peer. + pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete), + /// Handle an incoming `tx_signatures` message from the given peer. + pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures), + /// Handle an incoming `tx_init_rbf` message from the given peer. + pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf), + /// Handle an incoming `tx_ack_rbf` message from the given peer. + pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf), + /// Handle an incoming `tx_abort message` from the given peer. + pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort), /// Handle an incoming `update_add_htlc` message from the given peer. pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC), /// Handle an incoming `update_fulfill_htlc` message from the given peer. @@ -5924,7 +7868,6 @@ pub struct ChannelMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Handle an incoming `channel_reestablish` message from the given peer. pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish), @@ -5935,15 +7878,18 @@ pub struct ChannelMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports. + /// + /// If it's `None`, then no particular network chain hash compatibility will be enforced when + /// connecting to peers. + pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. @@ -5957,12 +7903,23 @@ pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessag ChannelMessageHandler { this_arg: orig.this_arg, handle_open_channel: Clone::clone(&orig.handle_open_channel), + handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2), handle_accept_channel: Clone::clone(&orig.handle_accept_channel), + handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2), handle_funding_created: Clone::clone(&orig.handle_funding_created), handle_funding_signed: Clone::clone(&orig.handle_funding_signed), handle_channel_ready: Clone::clone(&orig.handle_channel_ready), handle_shutdown: Clone::clone(&orig.handle_shutdown), handle_closing_signed: Clone::clone(&orig.handle_closing_signed), + handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input), + handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output), + handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input), + handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output), + handle_tx_complete: Clone::clone(&orig.handle_tx_complete), + handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures), + handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf), + handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf), + handle_tx_abort: Clone::clone(&orig.handle_tx_abort), handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc), handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc), handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc), @@ -5978,6 +7935,7 @@ pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessag handle_error: Clone::clone(&orig.handle_error), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), + get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes), MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), free: Clone::clone(&orig.free), } @@ -5995,9 +7953,15 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) { (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) } + fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) { + (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false }) + } fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) { (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) } + fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) { + (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false }) + } fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) } @@ -6013,6 +7977,33 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) } + fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) { + (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) { + (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) { + (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) { + (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) { + (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) { + (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) { + (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) { + (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) { + (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false }) + } fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) } @@ -6062,6 +8053,11 @@ impl rustChannelMessageHandler for ChannelMessageHandler { let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } + fn get_genesis_hashes(&self) -> Option> { + let mut ret = (self.get_genesis_hashes)(self.this_arg); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_ret_0 }})} }; + local_ret + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used @@ -6096,20 +8092,16 @@ pub struct RoutingMessageHandler { pub this_arg: *mut c_void, /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, /// `false` or returning an `Err` otherwise. - #[must_use] pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` /// or returning an `Err` otherwise. - #[must_use] pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Handle an incoming `channel_update` message, returning true if it should be forwarded on, /// `false` or returning an `Err` otherwise. - #[must_use] pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Gets channel announcements and updates required to dump our routing table to a remote node, /// starting at the `short_channel_id` indicated by `starting_point` and including announcements /// for a single channel. - #[must_use] pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ, /// Gets a node announcement required to dump our routing table to a remote node, starting at /// the node *after* the provided pubkey and including up to one announcement immediately @@ -6118,7 +8110,6 @@ pub struct RoutingMessageHandler { /// /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement, /// Called when a connection is established with a peer. This can be used to /// perform routing table synchronization using a strategy defined by the @@ -6127,44 +8118,36 @@ pub struct RoutingMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Handles the reply of a query we initiated to learn about channels /// for a given range of blocks. We can expect to receive one or more /// replies to a single query. - #[must_use] pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles the reply of a query we initiated asking for routing gossip /// messages for a list of channels. We should receive this message when /// a node has completed its best effort to send us the pertaining routing /// gossip messages. - #[must_use] pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles when a peer asks us to send a list of `short_channel_id`s /// for the requested range of blocks. - #[must_use] pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles when a peer asks us to send routing gossip messages for a /// list of `short_channel_id`s. - #[must_use] pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages /// pending some async action. While there is no guarantee of the rate of future messages, the /// caller should seek to reduce the rate of new gossip messages handled, especially /// [`ChannelAnnouncement`]s. - #[must_use] pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool, /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, @@ -6302,7 +8285,6 @@ pub struct OnionMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to /// drop and refuse to forward onion messages to this peer. @@ -6310,14 +8292,12 @@ pub struct OnionMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of OnionMessageProvider for this object. pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider, @@ -6417,6 +8397,166 @@ pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_t local_res } #[no_mangle] +/// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read +pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) }) +} +#[no_mangle] +/// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write +pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read +pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) }) +} +#[no_mangle] +/// Read a TxAddInput from a byte array, created by TxAddInput_write +pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read +pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) }) +} +#[no_mangle] +/// Read a TxAddOutput from a byte array, created by TxAddOutput_write +pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read +pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) }) +} +#[no_mangle] +/// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write +pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read +pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) }) +} +#[no_mangle] +/// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write +pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxComplete object into a byte array which can be read by TxComplete_read +pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) }) +} +#[no_mangle] +/// Read a TxComplete from a byte array, created by TxComplete_write +pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read +pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) }) +} +#[no_mangle] +/// Read a TxSignatures from a byte array, created by TxSignatures_write +pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read +pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) }) +} +#[no_mangle] +/// Read a TxInitRbf from a byte array, created by TxInitRbf_write +pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read +pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) }) +} +#[no_mangle] +/// Read a TxAckRbf from a byte array, created by TxAckRbf_write +pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAbort object into a byte array which can be read by TxAbort_read +pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) }) +} +#[no_mangle] +/// Read a TxAbort from a byte array, created by TxAbort_write +pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) @@ -6577,6 +8717,22 @@ pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_typ local_res } #[no_mangle] +/// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read +pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) }) +} +#[no_mangle] +/// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write +pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index 004ba53..05afcdc 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -216,6 +216,12 @@ pub extern "C" fn RetryableSendFailure_route_not_found() -> RetryableSendFailure /// Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure pub extern "C" fn RetryableSendFailure_duplicate_payment() -> RetryableSendFailure { RetryableSendFailure::DuplicatePayment} +/// Checks if two RetryableSendFailures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn RetryableSendFailure_eq(a: &RetryableSendFailure, b: &RetryableSendFailure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one /// of several states. This enum is returned as the Err() type describing which state the payment /// is in, see the description of individual enum states for more. @@ -535,15 +541,13 @@ impl RecipientOnionFields { /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as /// multi-path payments require a recipient-provided secret. /// -/// Note that for spontaneous payments most lightning nodes do not currently support MPP -/// receives, thus you should generally never be providing a secret here for spontaneous -/// payments. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Some implementations may reject spontaneous payments with payment secrets, so you may only +/// want to provide a secret for a spontaneous payment if MPP is needed and you know your +/// recipient will not reject it. #[no_mangle] -pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::derived::COption_PaymentSecretZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).0 } } }; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_PaymentSecretZ::None } else { crate::c_types::derived::COption_PaymentSecretZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) }; local_inner_val } /// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat @@ -554,14 +558,12 @@ pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOn /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as /// multi-path payments require a recipient-provided secret. /// -/// Note that for spontaneous payments most lightning nodes do not currently support MPP -/// receives, thus you should generally never be providing a secret here for spontaneous -/// payments. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Some implementations may reject spontaneous payments with payment secrets, so you may only +/// want to provide a secret for a spontaneous payment if MPP is needed and you know your +/// recipient will not reject it. #[no_mangle] -pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::ThirtyTwoBytes) { - let mut local_val = if val.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(val.data) }) }; +pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_PaymentSecretZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ val_opt.take() }.data) }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = local_val; } /// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of @@ -604,8 +606,8 @@ pub extern "C" fn RecipientOnionFields_set_payment_metadata(this_ptr: &mut Recip /// Constructs a new RecipientOnionFields given each field #[must_use] #[no_mangle] -pub extern "C" fn RecipientOnionFields_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_metadata_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> RecipientOnionFields { - let mut local_payment_secret_arg = if payment_secret_arg.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret_arg.data) }) }; +pub extern "C" fn RecipientOnionFields_new(mut payment_secret_arg: crate::c_types::derived::COption_PaymentSecretZ, mut payment_metadata_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> RecipientOnionFields { + let mut local_payment_secret_arg = { /*payment_secret_arg*/ let payment_secret_arg_opt = payment_secret_arg; if payment_secret_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ payment_secret_arg_opt.take() }.data) }})} }; let mut local_payment_metadata_arg = { /*payment_metadata_arg*/ let payment_metadata_arg_opt = payment_metadata_arg; if payment_metadata_arg_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_arg_0 = Vec::new(); for mut item in { payment_metadata_arg_opt.take() }.into_rust().drain(..) { local_payment_metadata_arg_0.push( { item }); }; local_payment_metadata_arg_0 }})} }; RecipientOnionFields { inner: ObjOps::heap_alloc(nativeRecipientOnionFields { payment_secret: local_payment_secret_arg, @@ -667,10 +669,13 @@ pub extern "C" fn RecipientOnionFields_secret_only(mut payment_secret: crate::c_ } /// Creates a new [`RecipientOnionFields`] with no fields. This generally does not create -/// payable HTLCs except for spontaneous payments, i.e. this should generally only be used for -/// calls to [`ChannelManager::send_spontaneous_payment`]. +/// payable HTLCs except for single-path spontaneous payments, i.e. this should generally +/// only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending +/// a spontaneous MPP this will not work as all MPP require payment secrets; you may +/// instead want to use [`RecipientOnionFields::secret_only`]. /// /// [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment +/// [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only #[must_use] #[no_mangle] pub extern "C" fn RecipientOnionFields_spontaneous_empty() -> crate::lightning::ln::outbound_payment::RecipientOnionFields { diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 0842280..6ac1068 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -38,13 +38,23 @@ pub struct CustomMessageHandler { /// Handles the given message sent from `sender_node_id`, possibly producing messages for /// [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] /// to send. - #[must_use] pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::wire::Type, sender_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Returns the list of pending messages that were generated by the handler, clearing the list /// in the process. Each message is paired with the node id of the intended recipient. If no /// connection to the node exists, then the message is simply not sent. - #[must_use] pub get_and_clear_pending_msg: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ, + /// Gets the node feature flags which this handler itself supports. All available handlers are + /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + /// which are broadcasted in our [`NodeAnnouncement`] message. + /// + /// [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + /// Gets the init feature flags which should be sent to the given peer. All available handlers + /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + /// which are sent in our [`Init`] message. + /// + /// [`Init`]: crate::ln::msgs::Init + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of CustomMessageReader for this object. pub CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader, /// Frees any resources associated with this object given its this_arg pointer. @@ -59,6 +69,8 @@ pub(crate) extern "C" fn CustomMessageHandler_clone_fields(orig: &CustomMessageH this_arg: orig.this_arg, handle_custom_message: Clone::clone(&orig.handle_custom_message), get_and_clear_pending_msg: Clone::clone(&orig.get_and_clear_pending_msg), + provided_node_features: Clone::clone(&orig.provided_node_features), + provided_init_features: Clone::clone(&orig.provided_init_features), CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader_clone_fields(&orig.CustomMessageReader), free: Clone::clone(&orig.free), } @@ -84,6 +96,14 @@ impl rustCustomMessageHandler for CustomMessageHandler { let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1); local_ret_0 }); }; local_ret } + fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + let mut ret = (self.provided_node_features)(self.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { + let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used @@ -387,6 +407,34 @@ extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features( crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +impl From for crate::lightning::onion_message::offers::OffersMessageHandler { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_OffersMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_OffersMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::onion_message::offers::OffersMessageHandler { + crate::lightning::onion_message::offers::OffersMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + handle_message: IgnoringMessageHandler_OffersMessageHandler_handle_message, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ { + let mut ret = >::handle_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message.into_native()); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_OffersMessageZ::None } else { crate::c_types::derived::COption_OffersMessageZ::Some( { crate::lightning::onion_message::offers::OffersMessage::native_into(ret.unwrap()) }) }; + local_ret +} + impl From for crate::lightning::onion_message::messenger::CustomOnionMessageHandler { fn from(obj: nativeIgnoringMessageHandler) -> Self { let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -409,7 +457,8 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomOnionMessageHandler(this_arg: } } -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) { +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> crate::c_types::derived::COption_CustomOnionMessageContentsZ { unreachable!(); } #[must_use] @@ -476,6 +525,8 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomMessageHandler(this_arg: &Igno free: None, handle_custom_message: IgnoringMessageHandler_CustomMessageHandler_handle_custom_message, get_and_clear_pending_msg: IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_msg, + provided_node_features: IgnoringMessageHandler_CustomMessageHandler_provided_node_features, + provided_init_features: IgnoringMessageHandler_CustomMessageHandler_provided_init_features, CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -494,6 +545,16 @@ extern "C" fn IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), Into::into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { + let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { + let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} use lightning::ln::peer_handler::ErroringMessageHandler as nativeErroringMessageHandlerImport; @@ -601,12 +662,23 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, handle_open_channel: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel, + handle_open_channel_v2: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel_v2, handle_accept_channel: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel, + handle_accept_channel_v2: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel_v2, handle_funding_created: ErroringMessageHandler_ChannelMessageHandler_handle_funding_created, handle_funding_signed: ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed, handle_channel_ready: ErroringMessageHandler_ChannelMessageHandler_handle_channel_ready, handle_shutdown: ErroringMessageHandler_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed, + handle_tx_add_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input, + handle_tx_add_output: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output, + handle_tx_remove_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input, + handle_tx_remove_output: ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_output, + handle_tx_complete: ErroringMessageHandler_ChannelMessageHandler_handle_tx_complete, + handle_tx_signatures: ErroringMessageHandler_ChannelMessageHandler_handle_tx_signatures, + handle_tx_init_rbf: ErroringMessageHandler_ChannelMessageHandler_handle_tx_init_rbf, + handle_tx_ack_rbf: ErroringMessageHandler_ChannelMessageHandler_handle_tx_ack_rbf, + handle_tx_abort: ErroringMessageHandler_ChannelMessageHandler_handle_tx_abort, handle_update_add_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc, handle_update_fulfill_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc, handle_update_fail_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc, @@ -622,6 +694,7 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error, provided_node_features: ErroringMessageHandler_ChannelMessageHandler_provided_node_features, provided_init_features: ErroringMessageHandler_ChannelMessageHandler_provided_init_features, + get_genesis_hashes: ErroringMessageHandler_ChannelMessageHandler_get_genesis_hashes, MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -633,9 +706,15 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { + >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { + >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -651,6 +730,33 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { + >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { + >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { + >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { + >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { + >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { + >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { + >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { + >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { + >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -703,10 +809,16 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_feature let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +#[must_use] +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_get_genesis_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut ret = >::get_genesis_hashes(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) }; + local_ret +} use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport; -pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; +pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; /// Provides references to trait impls which handle different types of messages. #[must_use] @@ -789,27 +901,45 @@ pub extern "C" fn MessageHandler_get_route_handler(this_ptr: &MessageHandler) -> pub extern "C" fn MessageHandler_set_route_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::RoutingMessageHandler) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_handler = val; } -/// A message handler which handles onion messages. For now, this can only be an -/// [`IgnoringMessageHandler`]. +/// A message handler which handles onion messages. This should generally be an +/// [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. +/// +/// [`OnionMessenger`]: crate::onion_message::OnionMessenger #[no_mangle] pub extern "C" fn MessageHandler_get_onion_message_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::msgs::OnionMessageHandler { let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_message_handler; inner_val } -/// A message handler which handles onion messages. For now, this can only be an -/// [`IgnoringMessageHandler`]. +/// A message handler which handles onion messages. This should generally be an +/// [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. +/// +/// [`OnionMessenger`]: crate::onion_message::OnionMessenger #[no_mangle] pub extern "C" fn MessageHandler_set_onion_message_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::OnionMessageHandler) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_message_handler = val; } +/// A message handler which handles custom messages. The only LDK-provided implementation is +/// [`IgnoringMessageHandler`]. +#[no_mangle] +pub extern "C" fn MessageHandler_get_custom_message_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::peer_handler::CustomMessageHandler { + let mut inner_val = &mut this_ptr.get_native_mut_ref().custom_message_handler; + inner_val +} +/// A message handler which handles custom messages. The only LDK-provided implementation is +/// [`IgnoringMessageHandler`]. +#[no_mangle] +pub extern "C" fn MessageHandler_set_custom_message_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::peer_handler::CustomMessageHandler) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.custom_message_handler = val; +} /// Constructs a new MessageHandler given each field #[must_use] #[no_mangle] -pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler, mut onion_message_handler_arg: crate::lightning::ln::msgs::OnionMessageHandler) -> MessageHandler { +pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler, mut onion_message_handler_arg: crate::lightning::ln::msgs::OnionMessageHandler, mut custom_message_handler_arg: crate::lightning::ln::peer_handler::CustomMessageHandler) -> MessageHandler { MessageHandler { inner: ObjOps::heap_alloc(nativeMessageHandler { chan_handler: chan_handler_arg, route_handler: route_handler_arg, onion_message_handler: onion_message_handler_arg, + custom_message_handler: custom_message_handler_arg, }), is_owned: true } } /// Provides an object which can be used to send data to and which uniquely identifies a connection @@ -846,7 +976,6 @@ pub struct SocketDescriptor { /// (indicating that read events should be paused to prevent DoS in the send buffer), /// `resume_read` may be set indicating that read events on this descriptor should resume. A /// `resume_read` of false carries no meaning, and should not cause any action. - #[must_use] pub send_data: extern "C" fn (this_arg: *mut c_void, data: crate::c_types::u8slice, resume_read: bool) -> usize, /// Disconnect the socket pointed to by this SocketDescriptor. /// @@ -1011,7 +1140,7 @@ pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleErr } use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport; -pub(crate) type nativePeerManager = nativePeerManagerImport; +pub(crate) type nativePeerManager = nativePeerManagerImport; /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls /// socket events into messages which it passes on to its [`MessageHandler`]. @@ -1089,8 +1218,8 @@ impl PeerManager { /// minute should suffice. #[must_use] #[no_mangle] -pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut current_time: u32, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut custom_message_handler: crate::lightning::ln::peer_handler::CustomMessageHandler, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner) -> crate::lightning::ln::peer_handler::PeerManager { - let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, current_time, unsafe { &*ephemeral_random_data}, logger, custom_message_handler, node_signer); +pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut current_time: u32, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut node_signer: crate::lightning::sign::NodeSigner) -> crate::lightning::ln::peer_handler::PeerManager { + let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, current_time, unsafe { &*ephemeral_random_data}, logger, node_signer); crate::lightning::ln::peer_handler::PeerManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs index 849b981..a39f35e 100644 --- a/lightning-c-bindings/src/lightning/ln/wire.rs +++ b/lightning-c-bindings/src/lightning/ln/wire.rs @@ -30,7 +30,6 @@ pub struct CustomMessageReader { /// implementation and the message could be decoded, must return `Ok(Some(message))`. If the /// message type is unknown to the implementation, must return `Ok(None)`. If a decoding error /// occur, must return `Err(DecodeError::X)` where `X` details the encountered error. - #[must_use] pub read: extern "C" fn (this_arg: *const c_void, message_type: u16, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -95,7 +94,6 @@ pub struct Type { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the type identifying the message payload. - #[must_use] pub type_id: extern "C" fn (this_arg: *const c_void) -> u16, /// Return a human-readable "debug" string describing this object pub debug_str: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Str, diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 20cee4b..0f8a143 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -48,6 +48,7 @@ pub mod chain; pub mod ln; pub mod offers; pub mod routing; +pub mod sign; pub mod onion_message; pub mod blinded_path; pub mod events; diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs index 778d5b4..2ad519a 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -8,9 +8,9 @@ //! Data structures and encoding for `invoice` messages. //! -//! An [`Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\" flow or -//! from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment then sends -//! the invoice to the intended payer, who will then pay it. +//! A [`Bolt12Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\" +//! flow or from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment +//! then sends the invoice to the intended payer, who will then pay it. //! //! The payment recipient must include a [`PaymentHash`], so as to reveal the preimage upon payment //! receipt, and one or more [`BlindedPath`]s for the payer to use when sending the payment. @@ -30,10 +30,10 @@ //! # use lightning::offers::invoice::BlindedPayInfo; //! # use lightning::blinded_path::BlindedPath; //! # -//! # fn create_payment_paths() -> Vec<(BlindedPath, BlindedPayInfo)> { unimplemented!() } +//! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() } //! # fn create_payment_hash() -> PaymentHash { unimplemented!() } //! # -//! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let payment_paths = create_payment_paths(); //! let payment_hash = create_payment_hash(); //! let secp_ctx = Secp256k1::new(); @@ -58,7 +58,7 @@ //! # Ok(()) //! # } //! -//! # fn parse_refund(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse_refund(bytes: Vec) -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! # let payment_paths = create_payment_paths(); //! # let payment_hash = create_payment_hash(); //! # let secp_ctx = Secp256k1::new(); @@ -95,18 +95,18 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; -use lightning::offers::invoice::UnsignedInvoice as nativeUnsignedInvoiceImport; -pub(crate) type nativeUnsignedInvoice = nativeUnsignedInvoiceImport<'static>; +use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport; +pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport<'static>; -/// A semantically valid [`Invoice`] that hasn't been signed. +/// A semantically valid [`Bolt12Invoice`] that hasn't been signed. #[must_use] #[repr(C)] -pub struct UnsignedInvoice { +pub struct UnsignedBolt12Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeUnsignedInvoice, + pub inner: *mut nativeUnsignedBolt12Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -114,31 +114,31 @@ pub struct UnsignedInvoice { pub is_owned: bool, } -impl Drop for UnsignedInvoice { +impl Drop for UnsignedBolt12Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeUnsignedInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the UnsignedInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn UnsignedInvoice_free(this_obj: UnsignedInvoice) { } +pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UnsignedInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoice) }; +pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) }; } #[allow(unused)] -impl UnsignedInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoice { +impl UnsignedBolt12Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -148,12 +148,180 @@ impl UnsignedInvoice { /// The public key corresponding to the key needed to sign the invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedInvoice) -> crate::c_types::PublicKey { +pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); crate::c_types::PublicKey::from_rust(&ret) } +use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport; +pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport; + +/// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`]. +/// +/// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent +/// directly after scanning a refund. It includes all the information needed to pay a recipient. +/// +/// [`Offer`]: crate::offers::offer::Offer +/// [`Refund`]: crate::offers::refund::Refund +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +#[must_use] +#[repr(C)] +pub struct Bolt12Invoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12Invoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Bolt12Invoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) }; +} +#[allow(unused)] +impl Bolt12Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Bolt12Invoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12Invoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12Invoice +pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice { + orig.clone() +} +/// A complete description of the purpose of the originating offer or refund. Intended to be +/// displayed to the user but with the caveat that it has not been verified in any way. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); + crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Duration since the Unix epoch when the invoice was created. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at(); + ret.as_secs() +} + +/// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore +/// should no longer be paid. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry(); + ret.as_secs() +} + +/// Whether the invoice has expired. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// SHA256 hash of the payment preimage that will be given in return for paying the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.0 } +} + +/// The minimum amount required for a successful payment of the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + ret +} + +/// Features pertaining to paying an invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); + crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } +} + +/// The public key corresponding to the key used to sign the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// Hash that was used for signing the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +/// Verifies that the invoice was for a request or refund created using the given key. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); + ret +} + +#[no_mangle] +/// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read +pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) }) +} + use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport; pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport; diff --git a/lightning-c-bindings/src/lightning/offers/invoice_error.rs b/lightning-c-bindings/src/lightning/offers/invoice_error.rs new file mode 100644 index 0000000..374c5e1 --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/invoice_error.rs @@ -0,0 +1,260 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and encoding for `invoice_error` messages. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::invoice_error::InvoiceError as nativeInvoiceErrorImport; +pub(crate) type nativeInvoiceError = nativeInvoiceErrorImport; + +/// An error in response to an [`InvoiceRequest`] or an [`Bolt12Invoice`]. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[repr(C)] +pub struct InvoiceError { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InvoiceError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceError_free(this_obj: InvoiceError) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceError) }; +} +#[allow(unused)] +impl InvoiceError { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceError { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceError { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceError { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn InvoiceError_get_erroneous_field(this_ptr: &InvoiceError) -> crate::lightning::offers::invoice_error::ErroneousField { + let mut inner_val = &mut this_ptr.get_native_mut_ref().erroneous_field; + let mut local_inner_val = crate::lightning::offers::invoice_error::ErroneousField { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::offers::invoice_error::ErroneousField<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn InvoiceError_set_erroneous_field(this_ptr: &mut InvoiceError, mut val: crate::lightning::offers::invoice_error::ErroneousField) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.erroneous_field = local_val; +} +/// An explanation of the error. +#[no_mangle] +pub extern "C" fn InvoiceError_get_message(this_ptr: &InvoiceError) -> crate::lightning::util::string::UntrustedString { + let mut inner_val = &mut this_ptr.get_native_mut_ref().message; + crate::lightning::util::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::string::UntrustedString<>) as *mut _) }, is_owned: false } +} +/// An explanation of the error. +#[no_mangle] +pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: crate::lightning::util::string::UntrustedString) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.message = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new InvoiceError given each field +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceError_new(mut erroneous_field_arg: crate::lightning::offers::invoice_error::ErroneousField, mut message_arg: crate::lightning::util::string::UntrustedString) -> InvoiceError { + let mut local_erroneous_field_arg = if erroneous_field_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(erroneous_field_arg.take_inner()) } }) }; + InvoiceError { inner: ObjOps::heap_alloc(nativeInvoiceError { + erroneous_field: local_erroneous_field_arg, + message: *unsafe { Box::from_raw(message_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for InvoiceError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceError>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceError +pub extern "C" fn InvoiceError_clone(orig: &InvoiceError) -> InvoiceError { + orig.clone() +} + +use lightning::offers::invoice_error::ErroneousField as nativeErroneousFieldImport; +pub(crate) type nativeErroneousField = nativeErroneousFieldImport; + +/// The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[repr(C)] +pub struct ErroneousField { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeErroneousField, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ErroneousField { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeErroneousField>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ErroneousField_free(this_obj: ErroneousField) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ErroneousField_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeErroneousField) }; +} +#[allow(unused)] +impl ErroneousField { + pub(crate) fn get_native_ref(&self) -> &'static nativeErroneousField { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeErroneousField { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeErroneousField { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The type number of the TLV field containing the error. +#[no_mangle] +pub extern "C" fn ErroneousField_get_tlv_fieldnum(this_ptr: &ErroneousField) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().tlv_fieldnum; + *inner_val +} +/// The type number of the TLV field containing the error. +#[no_mangle] +pub extern "C" fn ErroneousField_set_tlv_fieldnum(this_ptr: &mut ErroneousField, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tlv_fieldnum = val; +} +/// A value to use for the TLV field to avoid the error. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ErroneousField_get_suggested_value(this_ptr: &ErroneousField) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut inner_val = this_ptr.get_native_mut_ref().suggested_value.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { item }); }; local_inner_val_0.into() }) }; + local_inner_val +} +/// A value to use for the TLV field to avoid the error. +#[no_mangle] +pub extern "C" fn ErroneousField_set_suggested_value(this_ptr: &mut ErroneousField, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { item }); }; local_val_0 }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.suggested_value = local_val; +} +/// Constructs a new ErroneousField given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ErroneousField_new(mut tlv_fieldnum_arg: u64, mut suggested_value_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> ErroneousField { + let mut local_suggested_value_arg = { /*suggested_value_arg*/ let suggested_value_arg_opt = suggested_value_arg; if suggested_value_arg_opt.is_none() { None } else { Some({ { let mut local_suggested_value_arg_0 = Vec::new(); for mut item in { suggested_value_arg_opt.take() }.into_rust().drain(..) { local_suggested_value_arg_0.push( { item }); }; local_suggested_value_arg_0 }})} }; + ErroneousField { inner: ObjOps::heap_alloc(nativeErroneousField { + tlv_fieldnum: tlv_fieldnum_arg, + suggested_value: local_suggested_value_arg, + }), is_owned: true } +} +impl Clone for ErroneousField { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeErroneousField>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ErroneousField_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeErroneousField)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ErroneousField +pub extern "C" fn ErroneousField_clone(orig: &ErroneousField) -> ErroneousField { + orig.clone() +} +#[no_mangle] +/// Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read +pub extern "C" fn InvoiceError_write(obj: &crate::lightning::offers::invoice_error::InvoiceError) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn InvoiceError_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceError) }) +} +#[no_mangle] +/// Read a InvoiceError from a byte array, created by InvoiceError_write +pub extern "C" fn InvoiceError_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceErrorDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_error::InvoiceError { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/offers/invoice_request.rs b/lightning-c-bindings/src/lightning/offers/invoice_request.rs index fb0e322..b458687 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_request.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_request.rs @@ -10,12 +10,12 @@ //! //! An [`InvoiceRequest`] can be built from a parsed [`Offer`] as an \"offer to be paid\". It is //! typically constructed by a customer and sent to the merchant who had published the corresponding -//! offer. The recipient of the request responds with an [`Invoice`]. +//! offer. The recipient of the request responds with a [`Bolt12Invoice`]. //! //! For an \"offer for money\" (e.g., refund, ATM withdrawal), where an offer doesn't exist as a //! precursor, see [`Refund`]. //! -//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice //! [`Refund`]: crate::offers::refund::Refund //! //! ``` @@ -29,7 +29,7 @@ //! use lightning::offers::offer::Offer; //! use lightning::util::ser::Writeable; //! -//! # fn parse() -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse() -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); @@ -114,12 +114,12 @@ impl UnsignedInvoiceRequest { use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport; pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport; -/// An `InvoiceRequest` is a request for an [`Invoice`] formulated from an [`Offer`]. +/// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. /// /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request /// specifies these such that its recipient can send an invoice for payment. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice /// [`Offer`]: crate::offers::offer::Offer #[must_use] #[repr(C)] @@ -255,6 +255,19 @@ pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers: local_ret } +/// Verifies that the request was for an offer created using the given key. Returns the derived +/// keys need to sign an [`Bolt12Invoice`] for the request if they could be extracted from the +/// metadata. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_verify(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_COption_KeyPairZNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = if o.is_none() { crate::c_types::derived::COption_KeyPairZ::None } else { crate::c_types::derived::COption_KeyPairZ::Some( { crate::c_types::SecretKey::from_rust(o.unwrap().secret_key()) }) }; local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + #[no_mangle] /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z { diff --git a/lightning-c-bindings/src/lightning/offers/mod.rs b/lightning-c-bindings/src/lightning/offers/mod.rs index 41c8bef..0ea6089 100644 --- a/lightning-c-bindings/src/lightning/offers/mod.rs +++ b/lightning-c-bindings/src/lightning/offers/mod.rs @@ -20,6 +20,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod invoice; +pub mod invoice_error; pub mod invoice_request; pub mod offer; pub mod parse; diff --git a/lightning-c-bindings/src/lightning/offers/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs index bef11fa..a5d19c3 100644 --- a/lightning-c-bindings/src/lightning/offers/offer.rs +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -23,7 +23,7 @@ //! //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::offer::{Offer, OfferBuilder, Quantity}; -//! use lightning::offers::parse::ParseError; +//! use lightning::offers::parse::Bolt12ParseError; //! use lightning::util::ser::{Readable, Writeable}; //! //! # use lightning::blinded_path::BlindedPath; @@ -34,7 +34,7 @@ //! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] -//! # fn build() -> Result<(), ParseError> { +//! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); @@ -80,8 +80,8 @@ pub(crate) type nativeOffer = nativeOfferImport; /// An `Offer` is a potentially long-lived proposal for payment of a good or service. /// /// An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a -/// customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to -/// cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. +/// customer may request an [`Bolt12Invoice`] for a specific quantity and using an amount sufficient +/// to cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. /// /// Offers may be denominated in currency other than bitcoin but are ultimately paid using the /// latter. @@ -89,7 +89,7 @@ pub(crate) type nativeOffer = nativeOfferImport; /// Through the use of [`BlindedPath`]s, offers provide recipient privacy. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[repr(C)] pub struct Offer { @@ -437,3 +437,19 @@ pub(crate) extern "C" fn Quantity_clone_void(this_ptr: *const c_void) -> *mut c_ pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity { orig.clone() } +#[no_mangle] +/// Read a Offer object from a string +pub extern "C" fn Offer_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_OfferBolt12ParseErrorZ { + match lightning::offers::offer::Offer::from_str(s.into_str()) { + Ok(r) => { + crate::c_types::CResultTempl::ok( + crate::lightning::offers::offer::Offer { inner: ObjOps::heap_alloc(r), is_owned: true } + ) + }, + Err(e) => { + crate::c_types::CResultTempl::err( + crate::lightning::offers::parse::Bolt12ParseError { inner: ObjOps::heap_alloc(e), is_owned: true } + ) + }, + }.into() +} diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs index c1664e8..7730cc1 100644 --- a/lightning-c-bindings/src/lightning/offers/parse.rs +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -27,3 +27,369 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } + +use lightning::offers::parse::Bolt12ParseError as nativeBolt12ParseErrorImport; +pub(crate) type nativeBolt12ParseError = nativeBolt12ParseErrorImport; + +/// Error when parsing a bech32 encoded message using [`str::parse`]. +#[must_use] +#[repr(C)] +pub struct Bolt12ParseError { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12ParseError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Bolt12ParseError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12ParseError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12ParseError_free(this_obj: Bolt12ParseError) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12ParseError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12ParseError) }; +} +#[allow(unused)] +impl Bolt12ParseError { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12ParseError { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12ParseError { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12ParseError { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Bolt12ParseError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12ParseError>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12ParseError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12ParseError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12ParseError +pub extern "C" fn Bolt12ParseError_clone(orig: &Bolt12ParseError) -> Bolt12ParseError { + orig.clone() +} +/// Error when interpreting a TLV stream as a specific type. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Bolt12SemanticError { + /// The current [`std::time::SystemTime`] is past the offer or invoice's expiration. + AlreadyExpired, + /// The provided chain hash does not correspond to a supported chain. + UnsupportedChain, + /// A chain was provided but was not expected. + UnexpectedChain, + /// An amount was expected but was missing. + MissingAmount, + /// The amount exceeded the total bitcoin supply. + InvalidAmount, + /// An amount was provided but was not sufficient in value. + InsufficientAmount, + /// An amount was provided but was not expected. + UnexpectedAmount, + /// A currency was provided that is not supported. + UnsupportedCurrency, + /// A feature was required but is unknown. + UnknownRequiredFeatures, + /// Features were provided but were not expected. + UnexpectedFeatures, + /// A required description was not provided. + MissingDescription, + /// A signing pubkey was not provided. + MissingSigningPubkey, + /// A signing pubkey was provided but a different one was expected. + InvalidSigningPubkey, + /// A signing pubkey was provided but was not expected. + UnexpectedSigningPubkey, + /// A quantity was expected but was missing. + MissingQuantity, + /// An unsupported quantity was provided. + InvalidQuantity, + /// A quantity or quantity bounds was provided but was not expected. + UnexpectedQuantity, + /// Metadata could not be used to verify the offers message. + InvalidMetadata, + /// Metadata was provided but was not expected. + UnexpectedMetadata, + /// Payer metadata was expected but was missing. + MissingPayerMetadata, + /// A payer id was expected but was missing. + MissingPayerId, + /// Blinded paths were expected but were missing. + MissingPaths, + /// The blinded payinfo given does not match the number of blinded path hops. + InvalidPayInfo, + /// An invoice creation time was expected but was missing. + MissingCreationTime, + /// An invoice payment hash was expected but was missing. + MissingPaymentHash, + /// A signature was expected but was missing. + MissingSignature, +} +use lightning::offers::parse::Bolt12SemanticError as Bolt12SemanticErrorImport; +pub(crate) type nativeBolt12SemanticError = Bolt12SemanticErrorImport; + +impl Bolt12SemanticError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBolt12SemanticError { + match self { + Bolt12SemanticError::AlreadyExpired => nativeBolt12SemanticError::AlreadyExpired, + Bolt12SemanticError::UnsupportedChain => nativeBolt12SemanticError::UnsupportedChain, + Bolt12SemanticError::UnexpectedChain => nativeBolt12SemanticError::UnexpectedChain, + Bolt12SemanticError::MissingAmount => nativeBolt12SemanticError::MissingAmount, + Bolt12SemanticError::InvalidAmount => nativeBolt12SemanticError::InvalidAmount, + Bolt12SemanticError::InsufficientAmount => nativeBolt12SemanticError::InsufficientAmount, + Bolt12SemanticError::UnexpectedAmount => nativeBolt12SemanticError::UnexpectedAmount, + Bolt12SemanticError::UnsupportedCurrency => nativeBolt12SemanticError::UnsupportedCurrency, + Bolt12SemanticError::UnknownRequiredFeatures => nativeBolt12SemanticError::UnknownRequiredFeatures, + Bolt12SemanticError::UnexpectedFeatures => nativeBolt12SemanticError::UnexpectedFeatures, + Bolt12SemanticError::MissingDescription => nativeBolt12SemanticError::MissingDescription, + Bolt12SemanticError::MissingSigningPubkey => nativeBolt12SemanticError::MissingSigningPubkey, + Bolt12SemanticError::InvalidSigningPubkey => nativeBolt12SemanticError::InvalidSigningPubkey, + Bolt12SemanticError::UnexpectedSigningPubkey => nativeBolt12SemanticError::UnexpectedSigningPubkey, + Bolt12SemanticError::MissingQuantity => nativeBolt12SemanticError::MissingQuantity, + Bolt12SemanticError::InvalidQuantity => nativeBolt12SemanticError::InvalidQuantity, + Bolt12SemanticError::UnexpectedQuantity => nativeBolt12SemanticError::UnexpectedQuantity, + Bolt12SemanticError::InvalidMetadata => nativeBolt12SemanticError::InvalidMetadata, + Bolt12SemanticError::UnexpectedMetadata => nativeBolt12SemanticError::UnexpectedMetadata, + Bolt12SemanticError::MissingPayerMetadata => nativeBolt12SemanticError::MissingPayerMetadata, + Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, + Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, + Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, + Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBolt12SemanticError { + match self { + Bolt12SemanticError::AlreadyExpired => nativeBolt12SemanticError::AlreadyExpired, + Bolt12SemanticError::UnsupportedChain => nativeBolt12SemanticError::UnsupportedChain, + Bolt12SemanticError::UnexpectedChain => nativeBolt12SemanticError::UnexpectedChain, + Bolt12SemanticError::MissingAmount => nativeBolt12SemanticError::MissingAmount, + Bolt12SemanticError::InvalidAmount => nativeBolt12SemanticError::InvalidAmount, + Bolt12SemanticError::InsufficientAmount => nativeBolt12SemanticError::InsufficientAmount, + Bolt12SemanticError::UnexpectedAmount => nativeBolt12SemanticError::UnexpectedAmount, + Bolt12SemanticError::UnsupportedCurrency => nativeBolt12SemanticError::UnsupportedCurrency, + Bolt12SemanticError::UnknownRequiredFeatures => nativeBolt12SemanticError::UnknownRequiredFeatures, + Bolt12SemanticError::UnexpectedFeatures => nativeBolt12SemanticError::UnexpectedFeatures, + Bolt12SemanticError::MissingDescription => nativeBolt12SemanticError::MissingDescription, + Bolt12SemanticError::MissingSigningPubkey => nativeBolt12SemanticError::MissingSigningPubkey, + Bolt12SemanticError::InvalidSigningPubkey => nativeBolt12SemanticError::InvalidSigningPubkey, + Bolt12SemanticError::UnexpectedSigningPubkey => nativeBolt12SemanticError::UnexpectedSigningPubkey, + Bolt12SemanticError::MissingQuantity => nativeBolt12SemanticError::MissingQuantity, + Bolt12SemanticError::InvalidQuantity => nativeBolt12SemanticError::InvalidQuantity, + Bolt12SemanticError::UnexpectedQuantity => nativeBolt12SemanticError::UnexpectedQuantity, + Bolt12SemanticError::InvalidMetadata => nativeBolt12SemanticError::InvalidMetadata, + Bolt12SemanticError::UnexpectedMetadata => nativeBolt12SemanticError::UnexpectedMetadata, + Bolt12SemanticError::MissingPayerMetadata => nativeBolt12SemanticError::MissingPayerMetadata, + Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, + Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, + Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, + Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeBolt12SemanticError) -> Self { + match native { + nativeBolt12SemanticError::AlreadyExpired => Bolt12SemanticError::AlreadyExpired, + nativeBolt12SemanticError::UnsupportedChain => Bolt12SemanticError::UnsupportedChain, + nativeBolt12SemanticError::UnexpectedChain => Bolt12SemanticError::UnexpectedChain, + nativeBolt12SemanticError::MissingAmount => Bolt12SemanticError::MissingAmount, + nativeBolt12SemanticError::InvalidAmount => Bolt12SemanticError::InvalidAmount, + nativeBolt12SemanticError::InsufficientAmount => Bolt12SemanticError::InsufficientAmount, + nativeBolt12SemanticError::UnexpectedAmount => Bolt12SemanticError::UnexpectedAmount, + nativeBolt12SemanticError::UnsupportedCurrency => Bolt12SemanticError::UnsupportedCurrency, + nativeBolt12SemanticError::UnknownRequiredFeatures => Bolt12SemanticError::UnknownRequiredFeatures, + nativeBolt12SemanticError::UnexpectedFeatures => Bolt12SemanticError::UnexpectedFeatures, + nativeBolt12SemanticError::MissingDescription => Bolt12SemanticError::MissingDescription, + nativeBolt12SemanticError::MissingSigningPubkey => Bolt12SemanticError::MissingSigningPubkey, + nativeBolt12SemanticError::InvalidSigningPubkey => Bolt12SemanticError::InvalidSigningPubkey, + nativeBolt12SemanticError::UnexpectedSigningPubkey => Bolt12SemanticError::UnexpectedSigningPubkey, + nativeBolt12SemanticError::MissingQuantity => Bolt12SemanticError::MissingQuantity, + nativeBolt12SemanticError::InvalidQuantity => Bolt12SemanticError::InvalidQuantity, + nativeBolt12SemanticError::UnexpectedQuantity => Bolt12SemanticError::UnexpectedQuantity, + nativeBolt12SemanticError::InvalidMetadata => Bolt12SemanticError::InvalidMetadata, + nativeBolt12SemanticError::UnexpectedMetadata => Bolt12SemanticError::UnexpectedMetadata, + nativeBolt12SemanticError::MissingPayerMetadata => Bolt12SemanticError::MissingPayerMetadata, + nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, + nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, + nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, + nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBolt12SemanticError) -> Self { + match native { + nativeBolt12SemanticError::AlreadyExpired => Bolt12SemanticError::AlreadyExpired, + nativeBolt12SemanticError::UnsupportedChain => Bolt12SemanticError::UnsupportedChain, + nativeBolt12SemanticError::UnexpectedChain => Bolt12SemanticError::UnexpectedChain, + nativeBolt12SemanticError::MissingAmount => Bolt12SemanticError::MissingAmount, + nativeBolt12SemanticError::InvalidAmount => Bolt12SemanticError::InvalidAmount, + nativeBolt12SemanticError::InsufficientAmount => Bolt12SemanticError::InsufficientAmount, + nativeBolt12SemanticError::UnexpectedAmount => Bolt12SemanticError::UnexpectedAmount, + nativeBolt12SemanticError::UnsupportedCurrency => Bolt12SemanticError::UnsupportedCurrency, + nativeBolt12SemanticError::UnknownRequiredFeatures => Bolt12SemanticError::UnknownRequiredFeatures, + nativeBolt12SemanticError::UnexpectedFeatures => Bolt12SemanticError::UnexpectedFeatures, + nativeBolt12SemanticError::MissingDescription => Bolt12SemanticError::MissingDescription, + nativeBolt12SemanticError::MissingSigningPubkey => Bolt12SemanticError::MissingSigningPubkey, + nativeBolt12SemanticError::InvalidSigningPubkey => Bolt12SemanticError::InvalidSigningPubkey, + nativeBolt12SemanticError::UnexpectedSigningPubkey => Bolt12SemanticError::UnexpectedSigningPubkey, + nativeBolt12SemanticError::MissingQuantity => Bolt12SemanticError::MissingQuantity, + nativeBolt12SemanticError::InvalidQuantity => Bolt12SemanticError::InvalidQuantity, + nativeBolt12SemanticError::UnexpectedQuantity => Bolt12SemanticError::UnexpectedQuantity, + nativeBolt12SemanticError::InvalidMetadata => Bolt12SemanticError::InvalidMetadata, + nativeBolt12SemanticError::UnexpectedMetadata => Bolt12SemanticError::UnexpectedMetadata, + nativeBolt12SemanticError::MissingPayerMetadata => Bolt12SemanticError::MissingPayerMetadata, + nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, + nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, + nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, + nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, + } + } +} +/// Creates a copy of the Bolt12SemanticError +#[no_mangle] +pub extern "C" fn Bolt12SemanticError_clone(orig: &Bolt12SemanticError) -> Bolt12SemanticError { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_already_expired() -> Bolt12SemanticError { + Bolt12SemanticError::AlreadyExpired} +#[no_mangle] +/// Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unsupported_chain() -> Bolt12SemanticError { + Bolt12SemanticError::UnsupportedChain} +#[no_mangle] +/// Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_chain() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedChain} +#[no_mangle] +/// Utility method to constructs a new MissingAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_amount() -> Bolt12SemanticError { + Bolt12SemanticError::MissingAmount} +#[no_mangle] +/// Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_amount() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidAmount} +#[no_mangle] +/// Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_insufficient_amount() -> Bolt12SemanticError { + Bolt12SemanticError::InsufficientAmount} +#[no_mangle] +/// Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_amount() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedAmount} +#[no_mangle] +/// Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unsupported_currency() -> Bolt12SemanticError { + Bolt12SemanticError::UnsupportedCurrency} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unknown_required_features() -> Bolt12SemanticError { + Bolt12SemanticError::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_features() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedFeatures} +#[no_mangle] +/// Utility method to constructs a new MissingDescription-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_description() -> Bolt12SemanticError { + Bolt12SemanticError::MissingDescription} +#[no_mangle] +/// Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::MissingSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::MissingQuantity} +#[no_mangle] +/// Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidQuantity} +#[no_mangle] +/// Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedQuantity} +#[no_mangle] +/// Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidMetadata} +#[no_mangle] +/// Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedMetadata} +#[no_mangle] +/// Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payer_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPayerMetadata} +#[no_mangle] +/// Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payer_id() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPayerId} +#[no_mangle] +/// Utility method to constructs a new MissingPaths-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_paths() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPaths} +#[no_mangle] +/// Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_pay_info() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidPayInfo} +#[no_mangle] +/// Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_creation_time() -> Bolt12SemanticError { + Bolt12SemanticError::MissingCreationTime} +#[no_mangle] +/// Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payment_hash() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPaymentHash} +#[no_mangle] +/// Utility method to constructs a new MissingSignature-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_signature() -> Bolt12SemanticError { + Bolt12SemanticError::MissingSignature} diff --git a/lightning-c-bindings/src/lightning/offers/refund.rs b/lightning-c-bindings/src/lightning/offers/refund.rs index 1e44848..fe35bc2 100644 --- a/lightning-c-bindings/src/lightning/offers/refund.rs +++ b/lightning-c-bindings/src/lightning/offers/refund.rs @@ -9,11 +9,11 @@ //! Data structures and encoding for refunds. //! //! A [`Refund`] is an \"offer for money\" and is typically constructed by a merchant and presented -//! directly to the customer. The recipient responds with an [`Invoice`] to be paid. +//! directly to the customer. The recipient responds with a [`Bolt12Invoice`] to be paid. //! //! This is an [`InvoiceRequest`] produced *not* in response to an [`Offer`]. //! -//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice //! [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest //! [`Offer`]: crate::offers::offer::Offer //! @@ -27,7 +27,7 @@ //! //! use bitcoin::network::constants::Network; //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; -//! use lightning::offers::parse::ParseError; +//! use lightning::offers::parse::Bolt12ParseError; //! use lightning::offers::refund::{Refund, RefundBuilder}; //! use lightning::util::ser::{Readable, Writeable}; //! @@ -39,7 +39,7 @@ //! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] -//! # fn build() -> Result<(), ParseError> { +//! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); @@ -82,13 +82,13 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::offers::refund::Refund as nativeRefundImport; pub(crate) type nativeRefund = nativeRefundImport; -/// A `Refund` is a request to send an [`Invoice`] without a preceding [`Offer`]. +/// A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`]. /// /// Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to /// recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a /// bitcoin ATM. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice /// [`Offer`]: crate::offers::offer::Offer #[must_use] #[repr(C)] @@ -283,3 +283,19 @@ pub extern "C" fn Refund_write(obj: &crate::lightning::offers::refund::Refund) - pub(crate) extern "C" fn Refund_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRefund) }) } +#[no_mangle] +/// Read a Refund object from a string +pub extern "C" fn Refund_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_RefundBolt12ParseErrorZ { + match lightning::offers::refund::Refund::from_str(s.into_str()) { + Ok(r) => { + crate::c_types::CResultTempl::ok( + crate::lightning::offers::refund::Refund { inner: ObjOps::heap_alloc(r), is_owned: true } + ) + }, + Err(e) => { + crate::c_types::CResultTempl::err( + crate::lightning::offers::parse::Bolt12ParseError { inner: ObjOps::heap_alloc(e), is_owned: true } + ) + }, + }.into() +} diff --git a/lightning-c-bindings/src/lightning/onion_message/messenger.rs b/lightning-c-bindings/src/lightning/onion_message/messenger.rs index 1018d03..0c98903 100644 --- a/lightning-c-bindings/src/lightning/onion_message/messenger.rs +++ b/lightning-c-bindings/src/lightning/onion_message/messenger.rs @@ -19,7 +19,7 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::onion_message::messenger::OnionMessenger as nativeOnionMessengerImport; -pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; +pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; /// A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be /// used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending @@ -32,9 +32,9 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport, destination: Destination) -> Result { +/// # unimplemented!() +/// # } +/// # } /// # let seed = [42u8; 32]; /// # let time = Duration::from_secs(123456); /// # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos()); @@ -53,10 +59,15 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport @@ -139,6 +156,253 @@ impl OnionMessenger { ret } } +/// A trait defining behavior for routing an [`OnionMessage`]. +/// +/// [`OnionMessage`]: msgs::OnionMessage +#[repr(C)] +pub struct MessageRouter { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. + /// + /// [`OnionMessage`]: msgs::OnionMessage + pub find_path: extern "C" fn (this_arg: *const c_void, sender: crate::c_types::PublicKey, peers: crate::c_types::derived::CVec_PublicKeyZ, destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for MessageRouter {} +unsafe impl Sync for MessageRouter {} +#[no_mangle] +pub(crate) extern "C" fn MessageRouter_clone_fields(orig: &MessageRouter) -> MessageRouter { + MessageRouter { + this_arg: orig.this_arg, + find_path: Clone::clone(&orig.find_path), + free: Clone::clone(&orig.free), + } +} + +use lightning::onion_message::messenger::MessageRouter as rustMessageRouter; +impl rustMessageRouter for MessageRouter { + fn find_path(&self, mut sender: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut destination: lightning::onion_message::messenger::Destination) -> Result { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.find_path)(self.this_arg, crate::c_types::PublicKey::from_rust(&sender), local_peers.into(), crate::lightning::onion_message::messenger::Destination::native_into(destination)); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for MessageRouter { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn MessageRouter_free(this_ptr: MessageRouter) { } +impl Drop for MessageRouter { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} + +use lightning::onion_message::messenger::DefaultMessageRouter as nativeDefaultMessageRouterImport; +pub(crate) type nativeDefaultMessageRouter = nativeDefaultMessageRouterImport; + +/// A [`MessageRouter`] that always fails. +#[must_use] +#[repr(C)] +pub struct DefaultMessageRouter { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeDefaultMessageRouter, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DefaultMessageRouter { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDefaultMessageRouter>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_free(this_obj: DefaultMessageRouter) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn DefaultMessageRouter_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDefaultMessageRouter) }; +} +#[allow(unused)] +impl DefaultMessageRouter { + pub(crate) fn get_native_ref(&self) -> &'static nativeDefaultMessageRouter { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDefaultMessageRouter { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeDefaultMessageRouter { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Constructs a new DefaultMessageRouter given each field +#[must_use] +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_new() -> DefaultMessageRouter { + DefaultMessageRouter { inner: ObjOps::heap_alloc(lightning::onion_message::messenger::DefaultMessageRouter {}), is_owned: true } +} +impl From for crate::lightning::onion_message::messenger::MessageRouter { + fn from(obj: nativeDefaultMessageRouter) -> Self { + let mut rust_obj = DefaultMessageRouter { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = DefaultMessageRouter_as_MessageRouter(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(DefaultMessageRouter_free_void); + ret + } +} +/// Constructs a new MessageRouter which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_as_MessageRouter(this_arg: &DefaultMessageRouter) -> crate::lightning::onion_message::messenger::MessageRouter { + crate::lightning::onion_message::messenger::MessageRouter { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + find_path: DefaultMessageRouter_MessageRouter_find_path, + } +} + +#[must_use] +extern "C" fn DefaultMessageRouter_MessageRouter_find_path(this_arg: *const c_void, mut sender: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; + let mut ret = >::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, sender.into_rust(), local_peers, destination.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::OnionMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::onion_message::messenger::OnionMessagePath as nativeOnionMessagePathImport; +pub(crate) type nativeOnionMessagePath = nativeOnionMessagePathImport; + +/// A path for sending an [`msgs::OnionMessage`]. +#[must_use] +#[repr(C)] +pub struct OnionMessagePath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOnionMessagePath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OnionMessagePath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOnionMessagePath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OnionMessagePath_free(this_obj: OnionMessagePath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OnionMessagePath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessagePath) }; +} +#[allow(unused)] +impl OnionMessagePath { + pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessagePath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessagePath { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessagePath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Nodes on the path between the sender and the destination. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn OnionMessagePath_get_intermediate_nodes(this_ptr: &OnionMessagePath) -> crate::c_types::derived::CVec_PublicKeyZ { + let mut inner_val = this_ptr.get_native_mut_ref().intermediate_nodes.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + local_inner_val.into() +} +/// Nodes on the path between the sender and the destination. +#[no_mangle] +pub extern "C" fn OnionMessagePath_set_intermediate_nodes(this_ptr: &mut OnionMessagePath, mut val: crate::c_types::derived::CVec_PublicKeyZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.intermediate_nodes = local_val; +} +/// The recipient of the message. +#[no_mangle] +pub extern "C" fn OnionMessagePath_get_destination(this_ptr: &OnionMessagePath) -> crate::lightning::onion_message::messenger::Destination { + let mut inner_val = &mut this_ptr.get_native_mut_ref().destination; + crate::lightning::onion_message::messenger::Destination::from_native(inner_val) +} +/// The recipient of the message. +#[no_mangle] +pub extern "C" fn OnionMessagePath_set_destination(this_ptr: &mut OnionMessagePath, mut val: crate::lightning::onion_message::messenger::Destination) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.destination = val.into_native(); +} +/// Constructs a new OnionMessagePath given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessagePath_new(mut intermediate_nodes_arg: crate::c_types::derived::CVec_PublicKeyZ, mut destination_arg: crate::lightning::onion_message::messenger::Destination) -> OnionMessagePath { + let mut local_intermediate_nodes_arg = Vec::new(); for mut item in intermediate_nodes_arg.into_rust().drain(..) { local_intermediate_nodes_arg.push( { item.into_rust() }); }; + OnionMessagePath { inner: ObjOps::heap_alloc(nativeOnionMessagePath { + intermediate_nodes: local_intermediate_nodes_arg, + destination: destination_arg.into_native(), + }), is_owned: true } +} +impl Clone for OnionMessagePath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOnionMessagePath>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OnionMessagePath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessagePath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OnionMessagePath +pub extern "C" fn OnionMessagePath_clone(orig: &OnionMessagePath) -> OnionMessagePath { + orig.clone() +} /// The destination of an onion message. #[derive(Clone)] #[must_use] @@ -262,7 +526,7 @@ pub enum SendError { BufferFull, /// Failed to retrieve our node id from the provided [`NodeSigner`]. /// - /// [`NodeSigner`]: crate::chain::keysinterface::NodeSigner + /// [`NodeSigner`]: crate::sign::NodeSigner GetNodeIdFailed, /// We attempted to send to a blinded path where we are the introduction node, and failed to /// advance the blinded path to make the second hop the new introduction node. Either @@ -407,11 +671,10 @@ pub struct CustomOnionMessageHandler { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Called with the custom message that was received. - pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::CustomOnionMessageContents), + /// Called with the custom message that was received, returning a response to send, if any. + pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> crate::c_types::derived::COption_CustomOnionMessageContentsZ, /// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the /// message type is unknown. - #[must_use] pub read_custom_message: extern "C" fn (this_arg: *const c_void, message_type: u64, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -432,8 +695,10 @@ pub(crate) extern "C" fn CustomOnionMessageHandler_clone_fields(orig: &CustomOni use lightning::onion_message::messenger::CustomOnionMessageHandler as rustCustomOnionMessageHandler; impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { type CustomMessage = crate::lightning::onion_message::packet::CustomOnionMessageContents; - fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) { - (self.handle_custom_message)(self.this_arg, Into::into(msg)) + fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> Option { + let mut ret = (self.handle_custom_message)(self.this_arg, Into::into(msg)); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { { ret_opt.take() } }})} }; + local_ret } fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { let mut ret = (self.read_custom_message)(self.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); @@ -464,21 +729,21 @@ impl Drop for CustomOnionMessageHandler { /// their respective handlers. #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { - let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, custom_handler); +pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { + let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, message_router, offers_handler, custom_handler); crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. +/// Send an onion message with contents `message` to the destination of `path`. +/// /// See [`OnionMessenger`] for example usage. /// /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut intermediate_nodes: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { - let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { item.into_rust() }); }; +pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(&local_intermediate_nodes[..], destination.into_native(), message.into_native(), local_reply_path); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(*unsafe { Box::from_raw(path.take_inner()) }, message.into_native(), local_reply_path); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/onion_message/mod.rs b/lightning-c-bindings/src/lightning/onion_message/mod.rs index ad9bd5d..83d2f00 100644 --- a/lightning-c-bindings/src/lightning/onion_message/mod.rs +++ b/lightning-c-bindings/src/lightning/onion_message/mod.rs @@ -28,4 +28,5 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod messenger; +pub mod offers; pub mod packet; diff --git a/lightning-c-bindings/src/lightning/onion_message/offers.rs b/lightning-c-bindings/src/lightning/onion_message/offers.rs new file mode 100644 index 0000000..55fd8e1 --- /dev/null +++ b/lightning-c-bindings/src/lightning/onion_message/offers.rs @@ -0,0 +1,237 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Message handling for BOLT 12 Offers. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// A handler for an [`OnionMessage`] containing a BOLT 12 Offers message as its payload. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[repr(C)] +pub struct OffersMessageHandler { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Handles the given message by either responding with an [`Bolt12Invoice`], sending a payment, + /// or replying with an error. + pub handle_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for OffersMessageHandler {} +unsafe impl Sync for OffersMessageHandler {} +#[no_mangle] +pub(crate) extern "C" fn OffersMessageHandler_clone_fields(orig: &OffersMessageHandler) -> OffersMessageHandler { + OffersMessageHandler { + this_arg: orig.this_arg, + handle_message: Clone::clone(&orig.handle_message), + free: Clone::clone(&orig.free), + } +} + +use lightning::onion_message::offers::OffersMessageHandler as rustOffersMessageHandler; +impl rustOffersMessageHandler for OffersMessageHandler { + fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage) -> Option { + let mut ret = (self.handle_message)(self.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message)); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { { ret_opt.take() }.into_native() }})} }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for OffersMessageHandler { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn OffersMessageHandler_free(this_ptr: OffersMessageHandler) { } +impl Drop for OffersMessageHandler { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`]. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum OffersMessage { + /// A request for a [`Bolt12Invoice`] for a particular [`Offer`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + InvoiceRequest( + crate::lightning::offers::invoice_request::InvoiceRequest), + /// A [`Bolt12Invoice`] sent in response to an [`InvoiceRequest`] or a [`Refund`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + Invoice( + crate::lightning::offers::invoice::Bolt12Invoice), + /// An error from handling an [`OffersMessage`]. + InvoiceError( + crate::lightning::offers::invoice_error::InvoiceError), +} +use lightning::onion_message::offers::OffersMessage as OffersMessageImport; +pub(crate) type nativeOffersMessage = OffersMessageImport; + +impl OffersMessage { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeOffersMessage { + match self { + OffersMessage::InvoiceRequest (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeOffersMessage::InvoiceRequest ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + OffersMessage::Invoice (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeOffersMessage::Invoice ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + OffersMessage::InvoiceError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeOffersMessage::InvoiceError ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeOffersMessage { + match self { + OffersMessage::InvoiceRequest (mut a, ) => { + nativeOffersMessage::InvoiceRequest ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + OffersMessage::Invoice (mut a, ) => { + nativeOffersMessage::Invoice ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + OffersMessage::InvoiceError (mut a, ) => { + nativeOffersMessage::InvoiceError ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeOffersMessage) -> Self { + match native { + nativeOffersMessage::InvoiceRequest (ref a, ) => { + let mut a_nonref = Clone::clone(a); + OffersMessage::InvoiceRequest ( + crate::lightning::offers::invoice_request::InvoiceRequest { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeOffersMessage::Invoice (ref a, ) => { + let mut a_nonref = Clone::clone(a); + OffersMessage::Invoice ( + crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeOffersMessage::InvoiceError (ref a, ) => { + let mut a_nonref = Clone::clone(a); + OffersMessage::InvoiceError ( + crate::lightning::offers::invoice_error::InvoiceError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeOffersMessage) -> Self { + match native { + nativeOffersMessage::InvoiceRequest (mut a, ) => { + OffersMessage::InvoiceRequest ( + crate::lightning::offers::invoice_request::InvoiceRequest { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeOffersMessage::Invoice (mut a, ) => { + OffersMessage::Invoice ( + crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeOffersMessage::InvoiceError (mut a, ) => { + OffersMessage::InvoiceError ( + crate::lightning::offers::invoice_error::InvoiceError { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the OffersMessage +#[no_mangle] +pub extern "C" fn OffersMessage_free(this_ptr: OffersMessage) { } +/// Creates a copy of the OffersMessage +#[no_mangle] +pub extern "C" fn OffersMessage_clone(orig: &OffersMessage) -> OffersMessage { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequest-variant OffersMessage +pub extern "C" fn OffersMessage_invoice_request(a: crate::lightning::offers::invoice_request::InvoiceRequest) -> OffersMessage { + OffersMessage::InvoiceRequest(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Invoice-variant OffersMessage +pub extern "C" fn OffersMessage_invoice(a: crate::lightning::offers::invoice::Bolt12Invoice) -> OffersMessage { + OffersMessage::Invoice(a, ) +} +#[no_mangle] +/// Utility method to constructs a new InvoiceError-variant OffersMessage +pub extern "C" fn OffersMessage_invoice_error(a: crate::lightning::offers::invoice_error::InvoiceError) -> OffersMessage { + OffersMessage::InvoiceError(a, ) +} +/// Returns whether `tlv_type` corresponds to a TLV record for Offers. +#[must_use] +#[no_mangle] +pub extern "C" fn OffersMessage_is_known_type(mut tlv_type: u64) -> bool { + let mut ret = lightning::onion_message::offers::OffersMessage::is_known_type(tlv_type); + ret +} + +/// The TLV record type for the message as used in an `onionmsg_tlv` TLV stream. +#[must_use] +#[no_mangle] +pub extern "C" fn OffersMessage_tlv_type(this_arg: &crate::lightning::onion_message::offers::OffersMessage) -> u64 { + let mut ret = this_arg.to_native().tlv_type(); + ret +} + +#[no_mangle] +/// Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read +pub extern "C" fn OffersMessage_write(obj: &crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a OffersMessage from a byte array, created by OffersMessage_write +pub extern "C" fn OffersMessage_read(ser: crate::c_types::u8slice, arg_a: u64, arg_b: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_OffersMessageDecodeErrorZ { + let arg_a_conv = arg_a; + let arg_b_conv = arg_b; + let arg_conv = (arg_a_conv, arg_b_conv); + let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::offers::OffersMessage::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/onion_message/packet.rs b/lightning-c-bindings/src/lightning/onion_message/packet.rs index 9ca9037..8b253aa 100644 --- a/lightning-c-bindings/src/lightning/onion_message/packet.rs +++ b/lightning-c-bindings/src/lightning/onion_message/packet.rs @@ -21,6 +21,9 @@ use alloc::{vec::Vec, boxed::Box}; #[must_use] #[repr(C)] pub enum OnionMessageContents { + /// A message related to BOLT 12 Offers. + Offers( + crate::lightning::onion_message::offers::OffersMessage), /// A custom onion message specified by the user. Custom( crate::lightning::onion_message::packet::CustomOnionMessageContents), @@ -32,6 +35,11 @@ impl OnionMessageContents { #[allow(unused)] pub(crate) fn into_native(self) -> nativeOnionMessageContents { match self { + OnionMessageContents::Offers (mut a, ) => { + nativeOnionMessageContents::Offers ( + a.into_native(), + ) + }, OnionMessageContents::Custom (mut a, ) => { nativeOnionMessageContents::Custom ( a, @@ -42,6 +50,11 @@ impl OnionMessageContents { #[allow(unused)] pub(crate) fn native_into(native: nativeOnionMessageContents) -> Self { match native { + nativeOnionMessageContents::Offers (mut a, ) => { + OnionMessageContents::Offers ( + crate::lightning::onion_message::offers::OffersMessage::native_into(a), + ) + }, nativeOnionMessageContents::Custom (mut a, ) => { OnionMessageContents::Custom ( Into::into(a), @@ -54,6 +67,11 @@ impl OnionMessageContents { #[no_mangle] pub extern "C" fn OnionMessageContents_free(this_ptr: OnionMessageContents) { } #[no_mangle] +/// Utility method to constructs a new Offers-variant OnionMessageContents +pub extern "C" fn OnionMessageContents_offers(a: crate::lightning::onion_message::offers::OffersMessage) -> OnionMessageContents { + OnionMessageContents::Offers(a, ) +} +#[no_mangle] /// Utility method to constructs a new Custom-variant OnionMessageContents pub extern "C" fn OnionMessageContents_custom(a: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> OnionMessageContents { OnionMessageContents::Custom(a, ) @@ -65,7 +83,6 @@ pub struct CustomOnionMessageContents { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the TLV type identifying the message contents. MUST be >= 64. - #[must_use] pub tlv_type: extern "C" fn (this_arg: *const c_void) -> u64, /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, diff --git a/lightning-c-bindings/src/lightning/routing/gossip.rs b/lightning-c-bindings/src/lightning/routing/gossip.rs index 021fa0b..ed22681 100644 --- a/lightning-c-bindings/src/lightning/routing/gossip.rs +++ b/lightning-c-bindings/src/lightning/routing/gossip.rs @@ -509,6 +509,34 @@ pub extern "C" fn NetworkGraph_handle_network_update(this_arg: &crate::lightning unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_network_update(&network_update.to_native()) } +/// Gets the genesis hash for this network graph. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_get_genesis_hash(this_arg: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_genesis_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } +} + +/// Verifies the signature of a [`NodeAnnouncement`]. +/// +/// Returns an error if it is invalid. +#[no_mangle] +pub extern "C" fn verify_node_announcement(msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = lightning::routing::gossip::verify_node_announcement(msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + +/// Verifies all signatures included in a [`ChannelAnnouncement`]. +/// +/// Returns an error if one of the signatures is invalid. +#[no_mangle] +pub extern "C" fn verify_channel_announcement(msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = lightning::routing::gossip::verify_channel_announcement(msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + impl From for crate::lightning::ln::msgs::RoutingMessageHandler { fn from(obj: nativeP2PGossipSync) -> Self { let mut rust_obj = P2PGossipSync { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1178,7 +1206,7 @@ pub enum EffectiveCapacity { liquidity_msat: u64, }, /// The maximum HTLC amount in one direction as advertised on the gossip network. - MaximumHTLC { + AdvertisedMaxHTLC { /// The maximum HTLC amount denominated in millisatoshi. amount_msat: u64, }, @@ -1192,6 +1220,11 @@ pub enum EffectiveCapacity { /// A capacity sufficient to route any payment, typically used for private channels provided by /// an invoice. Infinite, + /// The maximum HTLC amount as provided by an invoice route hint. + HintMaxHTLC { + /// The maximum HTLC amount denominated in millisatoshi. + amount_msat: u64, + }, /// A capacity that is unknown possibly because either the chain state is unavailable to know /// the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network. Unknown, @@ -1209,9 +1242,9 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat_nonref, } }, - EffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + EffectiveCapacity::AdvertisedMaxHTLC {ref amount_msat, } => { let mut amount_msat_nonref = Clone::clone(amount_msat); - nativeEffectiveCapacity::MaximumHTLC { + nativeEffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat_nonref, } }, @@ -1224,6 +1257,12 @@ impl EffectiveCapacity { } }, EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::HintMaxHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = Clone::clone(amount_msat); + nativeEffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat_nonref, + } + }, EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, } } @@ -1235,8 +1274,8 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat, } }, - EffectiveCapacity::MaximumHTLC {mut amount_msat, } => { - nativeEffectiveCapacity::MaximumHTLC { + EffectiveCapacity::AdvertisedMaxHTLC {mut amount_msat, } => { + nativeEffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat, } }, @@ -1247,6 +1286,11 @@ impl EffectiveCapacity { } }, EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::HintMaxHTLC {mut amount_msat, } => { + nativeEffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat, + } + }, EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, } } @@ -1259,9 +1303,9 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat_nonref, } }, - nativeEffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + nativeEffectiveCapacity::AdvertisedMaxHTLC {ref amount_msat, } => { let mut amount_msat_nonref = Clone::clone(amount_msat); - EffectiveCapacity::MaximumHTLC { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat_nonref, } }, @@ -1274,6 +1318,12 @@ impl EffectiveCapacity { } }, nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::HintMaxHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = Clone::clone(amount_msat); + EffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat_nonref, + } + }, nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, } } @@ -1285,8 +1335,8 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat, } }, - nativeEffectiveCapacity::MaximumHTLC {mut amount_msat, } => { - EffectiveCapacity::MaximumHTLC { + nativeEffectiveCapacity::AdvertisedMaxHTLC {mut amount_msat, } => { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat, } }, @@ -1297,6 +1347,11 @@ impl EffectiveCapacity { } }, nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::HintMaxHTLC {mut amount_msat, } => { + EffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat, + } + }, nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, } } @@ -1317,9 +1372,9 @@ pub extern "C" fn EffectiveCapacity_exact_liquidity(liquidity_msat: u64) -> Effe } } #[no_mangle] -/// Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity -pub extern "C" fn EffectiveCapacity_maximum_htlc(amount_msat: u64) -> EffectiveCapacity { - EffectiveCapacity::MaximumHTLC { +/// Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_advertised_max_htlc(amount_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat, } } @@ -1336,6 +1391,13 @@ pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64, htlc_maximum_msat: pub extern "C" fn EffectiveCapacity_infinite() -> EffectiveCapacity { EffectiveCapacity::Infinite} #[no_mangle] +/// Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_hint_max_htlc(amount_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::HintMaxHTLC { + amount_msat, + } +} +#[no_mangle] /// Utility method to constructs a new Unknown-variant EffectiveCapacity pub extern "C" fn EffectiveCapacity_unknown() -> EffectiveCapacity { EffectiveCapacity::Unknown} @@ -2015,8 +2077,8 @@ pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: /// Store or update channel info from a channel announcement. /// -/// You probably don't want to call this directly, instead relying on a P2PGossipSync's -/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept +/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s +/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept /// routing messages from a source using a protocol other than the lightning P2P protocol. /// /// If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify @@ -2030,6 +2092,21 @@ pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &crate local_ret } +/// Store or update channel info from a channel announcement. +/// +/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s +/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept +/// routing messages from a source using a protocol other than the lightning P2P protocol. +/// +/// This will skip verification of if the channel is actually on-chain. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel_from_announcement_no_lookup(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement_no_lookup(msg.get_native_ref()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + /// Store or update channel info from a channel announcement without verifying the associated /// signatures. Because we aren't given the associated signatures here we cannot relay the /// channel announcement to any of our peers. diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index 2b7cc35..5e12f9e 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -70,8 +70,8 @@ impl DefaultRouter { /// Creates a new router. #[must_use] #[no_mangle] -pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes, mut scorer: crate::lightning::routing::scoring::LockableScore) -> crate::lightning::routing::router::DefaultRouter { - let mut ret = lightning::routing::router::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data, scorer); +pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes, mut scorer: crate::lightning::routing::scoring::LockableScore, mut score_params: crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> crate::lightning::routing::router::DefaultRouter { + let mut ret = lightning::routing::router::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data, scorer, *unsafe { Box::from_raw(score_params.take_inner()) }); crate::lightning::routing::router::DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -98,16 +98,16 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li } #[must_use] -extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, inflight_htlcs.get_native_ref()); + let mut ret = >::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] -extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, inflight_htlcs.get_native_ref(), ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); + let mut ret = >::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }, ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } @@ -118,17 +118,23 @@ pub struct Router { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. + /// Finds a [`Route`] for a payment between the given `payer` and a payee. + /// + /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + /// and [`RouteParameters::final_value_msat`], respectively. /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ, - /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes - /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment. + pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ, + /// Finds a [`Route`] for a payment between the given `payer` and a payee. + /// + /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + /// and [`RouteParameters::final_value_msat`], respectively. + /// + /// Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific + /// payment. /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ, + pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -147,15 +153,15 @@ pub(crate) extern "C" fn Router_clone_fields(orig: &Router) -> Router { use lightning::routing::router::Router as rustRouter; impl rustRouter for Router { - fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: &lightning::routing::router::InFlightHtlcs) -> Result { + fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result { let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; - let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, &crate::lightning::routing::router::InFlightHtlcs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inflight_htlcs as *const lightning::routing::router::InFlightHtlcs<>) as *mut _) }, is_owned: false }); + let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: &lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { + fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; - let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, &crate::lightning::routing::router::InFlightHtlcs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inflight_htlcs as *const lightning::routing::router::InFlightHtlcs<>) as *mut _) }, is_owned: false }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); + let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } @@ -279,8 +285,8 @@ pub extern "C" fn ScorerAccountingForInFlightHtlcs_as_Score(this_arg: &ScorerAcc } #[must_use] -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -381,6 +387,13 @@ pub extern "C" fn InFlightHtlcs_process_path(this_arg: &mut crate::lightning::ro unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.process_path(path.get_native_ref(), payer_node_id.into_rust()) } +/// Adds a known HTLC given the public key of the HTLC source, target, and short channel +/// id. +#[no_mangle] +pub extern "C" fn InFlightHtlcs_add_inflight_htlc(this_arg: &mut crate::lightning::routing::router::InFlightHtlcs, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut channel_scid: u64, mut used_msat: u64) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.add_inflight_htlc(source.get_native_ref(), target.get_native_ref(), channel_scid, used_msat) +} + /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel /// id. #[must_use] @@ -621,9 +634,9 @@ use lightning::routing::router::BlindedTail as nativeBlindedTailImport; pub(crate) type nativeBlindedTail = nativeBlindedTailImport; /// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in -/// their BOLT12 [`Invoice`]. +/// their [`Bolt12Invoice`]. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[repr(C)] pub struct BlindedTail { @@ -1017,11 +1030,9 @@ pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types: let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val; } -/// The `payment_params` 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`]. +/// The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. /// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// This is used by `ChannelManager` to track information which may be required for retries. /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -1030,11 +1041,9 @@ pub extern "C" fn Route_get_payment_params(this_ptr: &Route) -> crate::lightning let mut local_inner_val = crate::lightning::routing::router::PaymentParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::PaymentParameters<>) as *mut _ }, is_owned: false }; local_inner_val } -/// The `payment_params` 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`]. +/// The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. /// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// This is used by `ChannelManager` to track information which may be required for retries. /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -1094,7 +1103,7 @@ pub extern "C" fn Route_eq(a: &Route, b: &Route) -> bool { /// 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 [`find_route`]'s `params.final_value_msat`. +/// the amount passed to [`find_route`]'s `route_params.final_value_msat`. #[must_use] #[no_mangle] pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::router::Route) -> u64 { @@ -1133,10 +1142,7 @@ pub(crate) type nativeRouteParameters = nativeRouteParametersImport; /// Parameters needed to find a [`Route`]. /// -/// Passed to [`find_route`] and [`build_route_from_hops`], but also provided in -/// [`Event::PaymentPathFailed`]. -/// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// Passed to [`find_route`] and [`build_route_from_hops`]. #[must_use] #[repr(C)] pub struct RouteParameters { @@ -1270,7 +1276,7 @@ pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_ use lightning::routing::router::PaymentParameters as nativePaymentParametersImport; pub(crate) type nativePaymentParameters = nativePaymentParametersImport; -/// The recipient of a payment. +/// Information used to route a payment. #[must_use] #[repr(C)] pub struct PaymentParameters { @@ -1317,54 +1323,16 @@ impl PaymentParameters { ret } } -/// The node id of the payee. -#[no_mangle] -pub extern "C" fn PaymentParameters_get_payee_pubkey(this_ptr: &PaymentParameters) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payee_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The node id of the payee. -#[no_mangle] -pub extern "C" fn PaymentParameters_set_payee_pubkey(this_ptr: &mut PaymentParameters, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee_pubkey = val.into_rust(); -} -/// 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 -#[no_mangle] -pub extern "C" fn PaymentParameters_get_features(this_ptr: &PaymentParameters) -> crate::lightning::ln::features::InvoiceFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - let mut local_inner_val = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; - local_inner_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 val (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn PaymentParameters_set_features(this_ptr: &mut PaymentParameters, mut val: crate::lightning::ln::features::InvoiceFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = local_val; -} -/// Hints for routing to the payee, containing channels connecting the payee to public nodes. +/// Information about the payee, such as their features and route hints for their channels. #[no_mangle] -pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Hints { - let mut inner_val = &mut this_ptr.get_native_mut_ref().route_hints; - crate::lightning::routing::router::Hints::from_native(inner_val) +pub extern "C" fn PaymentParameters_get_payee(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Payee { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payee; + crate::lightning::routing::router::Payee::from_native(inner_val) } -/// Hints for routing to the payee, containing channels connecting the payee to public nodes. +/// Information about the payee, such as their features and route hints for their channels. #[no_mangle] -pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Hints) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_hints = val.into_native(); +pub extern "C" fn PaymentParameters_set_payee(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Payee) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee = val.into_native(); } /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch. #[no_mangle] @@ -1459,34 +1427,19 @@ pub extern "C" fn PaymentParameters_set_previously_failed_channels(this_ptr: &mu let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previously_failed_channels = local_val; } -/// The minimum CLTV delta at the end of the route. This value must not be zero. -#[no_mangle] -pub extern "C" fn PaymentParameters_get_final_cltv_expiry_delta(this_ptr: &PaymentParameters) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().final_cltv_expiry_delta; - *inner_val -} -/// The minimum CLTV delta at the end of the route. This value must not be zero. -#[no_mangle] -pub extern "C" fn PaymentParameters_set_final_cltv_expiry_delta(this_ptr: &mut PaymentParameters, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_cltv_expiry_delta = val; -} /// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::lightning::routing::router::Hints, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut final_cltv_expiry_delta_arg: u32) -> PaymentParameters { - let mut local_features_arg = if features_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_arg.take_inner()) } }) }; +pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters { let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None }; let mut local_previously_failed_channels_arg = Vec::new(); for mut item in previously_failed_channels_arg.into_rust().drain(..) { local_previously_failed_channels_arg.push( { item }); }; PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters { - payee_pubkey: payee_pubkey_arg.into_rust(), - features: local_features_arg, - route_hints: route_hints_arg.into_native(), + payee: payee_arg.into_native(), expiry_time: local_expiry_time_arg, max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg, max_path_count: max_path_count_arg, max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg, previously_failed_channels: local_previously_failed_channels_arg, - final_cltv_expiry_delta: final_cltv_expiry_delta_arg, }), is_owned: true } } impl Clone for PaymentParameters { @@ -1559,134 +1512,217 @@ pub extern "C" fn PaymentParameters_from_node_id(mut payee_pubkey: crate::c_type /// /// The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has /// provided. +/// +/// Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose +/// whether your router will be allowed to find a multi-part route for this payment. If you +/// set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via +/// [`RecipientOnionFields::secret_only`]. +/// +/// [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only +#[must_use] +#[no_mangle] +pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32, mut allow_mpp: bool) -> crate::lightning::routing::router::PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust(), final_cltv_expiry_delta, allow_mpp); + crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Creates parameters for paying to a blinded payee from the provided invoice. Sets +/// [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and +/// [`PaymentParameters::expiry_time`]. #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32) -> crate::lightning::routing::router::PaymentParameters { - let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust(), final_cltv_expiry_delta); +pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::routing::router::PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::from_bolt12_invoice(invoice.get_native_ref()); crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Routing hints for the tail of the route. +/// The recipient of a payment, differing based on whether they've hidden their identity with route +/// blinding. #[derive(Clone)] #[must_use] #[repr(C)] -pub enum Hints { +pub enum Payee { /// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves /// will be included in the final [`Route`]. - Blinded( - crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ), + Blinded { + /// Aggregated routing info and blinded paths, for routing to the payee without knowing their + /// node id. + route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, + /// Features supported by the payee. + /// + /// May be set from the payee's invoice. May be `None` if the invoice does not contain any + /// features. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + features: crate::lightning::ln::features::Bolt12InvoiceFeatures, + }, /// The recipient included these route hints in their BOLT11 invoice. - Clear( - crate::c_types::derived::CVec_RouteHintZ), -} -use lightning::routing::router::Hints as HintsImport; -pub(crate) type nativeHints = HintsImport; - -impl Hints { + Clear { + /// The node id of the payee. + node_id: crate::c_types::PublicKey, + /// Hints for routing to the payee, containing channels connecting the payee to public nodes. + route_hints: crate::c_types::derived::CVec_RouteHintZ, + /// 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`]: PaymentParameters::for_keysend + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + features: crate::lightning::ln::features::Bolt11InvoiceFeatures, + /// The minimum CLTV delta at the end of the route. This value must not be zero. + final_cltv_expiry_delta: u32, + }, +} +use lightning::routing::router::Payee as PayeeImport; +pub(crate) type nativePayee = PayeeImport; + +impl Payee { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeHints { + pub(crate) fn to_native(&self) -> nativePayee { match self { - Hints::Blinded (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item.to_rust(); let mut local_a_nonref_0 = (*unsafe { Box::from_raw(orig_a_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_nonref_0_1.take_inner()) }); local_a_nonref_0 }); }; - nativeHints::Blinded ( - local_a_nonref, - ) + Payee::Blinded {ref route_hints, ref features, } => { + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item.to_rust(); let mut local_route_hints_nonref_0 = (*unsafe { Box::from_raw(orig_route_hints_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_nonref_0_1.take_inner()) }); local_route_hints_nonref_0 }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) }; + nativePayee::Blinded { + route_hints: local_route_hints_nonref, + features: local_features_nonref, + } }, - Hints::Clear (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - nativeHints::Clear ( - local_a_nonref, - ) + Payee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) }; + let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta); + nativePayee::Clear { + node_id: node_id_nonref.into_rust(), + route_hints: local_route_hints_nonref, + features: local_features_nonref, + final_cltv_expiry_delta: final_cltv_expiry_delta_nonref, + } }, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeHints { + pub(crate) fn into_native(self) -> nativePayee { match self { - Hints::Blinded (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item.to_rust(); let mut local_a_0 = (*unsafe { Box::from_raw(orig_a_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_0_1.take_inner()) }); local_a_0 }); }; - nativeHints::Blinded ( - local_a, - ) + Payee::Blinded {mut route_hints, mut features, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item.to_rust(); let mut local_route_hints_0 = (*unsafe { Box::from_raw(orig_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_0_1.take_inner()) }); local_route_hints_0 }); }; + let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) }; + nativePayee::Blinded { + route_hints: local_route_hints, + features: local_features, + } }, - Hints::Clear (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - nativeHints::Clear ( - local_a, - ) + Payee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) }; + nativePayee::Clear { + node_id: node_id.into_rust(), + route_hints: local_route_hints, + features: local_features, + final_cltv_expiry_delta: final_cltv_expiry_delta, + } }, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeHints) -> Self { + pub(crate) fn from_native(native: &nativePayee) -> Self { match native { - nativeHints::Blinded (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item; let mut local_a_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_nonref_0_1), is_owned: true }).into(); local_a_nonref_0 }); }; - Hints::Blinded ( - local_a_nonref.into(), - ) + nativePayee::Blinded {ref route_hints, ref features, } => { + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item; let mut local_route_hints_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_1), is_owned: true }).into(); local_route_hints_nonref_0 }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + Payee::Blinded { + route_hints: local_route_hints_nonref.into(), + features: local_features_nonref, + } }, - nativeHints::Clear (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; - Hints::Clear ( - local_a_nonref.into(), - ) + nativePayee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta); + Payee::Clear { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + route_hints: local_route_hints_nonref.into(), + features: local_features_nonref, + final_cltv_expiry_delta: final_cltv_expiry_delta_nonref, + } }, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeHints) -> Self { + pub(crate) fn native_into(native: nativePayee) -> Self { match native { - nativeHints::Blinded (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item; let mut local_a_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_0_1), is_owned: true }).into(); local_a_0 }); }; - Hints::Blinded ( - local_a.into(), - ) + nativePayee::Blinded {mut route_hints, mut features, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item; let mut local_route_hints_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_0_1), is_owned: true }).into(); local_route_hints_0 }); }; + let mut local_features = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + Payee::Blinded { + route_hints: local_route_hints.into(), + features: local_features, + } }, - nativeHints::Clear (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; - Hints::Clear ( - local_a.into(), - ) + nativePayee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + Payee::Clear { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + route_hints: local_route_hints.into(), + features: local_features, + final_cltv_expiry_delta: final_cltv_expiry_delta, + } }, } } } -/// Frees any resources used by the Hints +/// Frees any resources used by the Payee #[no_mangle] -pub extern "C" fn Hints_free(this_ptr: Hints) { } -/// Creates a copy of the Hints +pub extern "C" fn Payee_free(this_ptr: Payee) { } +/// Creates a copy of the Payee #[no_mangle] -pub extern "C" fn Hints_clone(orig: &Hints) -> Hints { +pub extern "C" fn Payee_clone(orig: &Payee) -> Payee { orig.clone() } #[no_mangle] -/// Utility method to constructs a new Blinded-variant Hints -pub extern "C" fn Hints_blinded(a: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> Hints { - Hints::Blinded(a, ) +/// Utility method to constructs a new Blinded-variant Payee +pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, features: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> Payee { + Payee::Blinded { + route_hints, + features, + } } #[no_mangle] -/// Utility method to constructs a new Clear-variant Hints -pub extern "C" fn Hints_clear(a: crate::c_types::derived::CVec_RouteHintZ) -> Hints { - Hints::Clear(a, ) +/// Utility method to constructs a new Clear-variant Payee +pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning::ln::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee { + Payee::Clear { + node_id, + route_hints, + features, + final_cltv_expiry_delta, + } } -/// Generates a non-cryptographic 64-bit hash of the Hints. +/// Generates a non-cryptographic 64-bit hash of the Payee. #[no_mangle] -pub extern "C" fn Hints_hash(o: &Hints) -> u64 { +pub extern "C" fn Payee_hash(o: &Payee) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] let mut hasher = core::hash::SipHasher::new(); core::hash::Hash::hash(&o.to_native(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two Hintss contain equal inner contents. +/// Checks if two Payees contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn Hints_eq(a: &Hints, b: &Hints) -> bool { +pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } @@ -2006,10 +2042,12 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty } /// Finds a route from us (payer) to the given target node (payee). /// -/// If the payee provided features in their invoice, they should be provided via `params.payee`. +/// If the payee provided features in their invoice, they should be provided via the `payee` field +/// in the given [`RouteParameters::payment_params`]. /// 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 `params.payee`. +/// Private routing paths between a public node and the target may be included in the `payee` field +/// of [`RouteParameters::payment_params`]. /// /// 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 these channels @@ -2019,15 +2057,9 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty /// 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. -/// /// # Panics /// -/// Panics if first_hops contains channels without short_channel_ids; +/// Panics if first_hops contains channels without `short_channel_id`s; /// [`ChannelManager::list_usable_channels`] will never include such channels. /// /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels @@ -2036,9 +2068,9 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, unsafe { &*random_seed_bytes}); + let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, score_params.get_native_ref(), unsafe { &*random_seed_bytes}); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/routing/scoring.rs b/lightning-c-bindings/src/lightning/routing/scoring.rs index 820a7b1..f76cf9d 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -18,8 +18,8 @@ //! # //! # use lightning::routing::gossip::NetworkGraph; //! # use lightning::routing::router::{RouteParameters, find_route}; -//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters}; -//! # use lightning::chain::keysinterface::KeysManager; +//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters}; +//! # use lightning::sign::KeysManager; //! # use lightning::util::logger::{Logger, Record}; //! # use bitcoin::secp256k1::PublicKey; //! # @@ -31,18 +31,20 @@ //! # let logger = FakeLogger {}; //! # //! // Use the default channel penalties. -//! let params = ProbabilisticScoringParameters::default(); -//! let scorer = ProbabilisticScorer::new(params, &network_graph, &logger); +//! let params = ProbabilisticScoringFeeParameters::default(); +//! let decay_params = ProbabilisticScoringDecayParameters::default(); +//! let scorer = ProbabilisticScorer::new(decay_params, &network_graph, &logger); //! //! // Or use custom channel penalties. -//! let params = ProbabilisticScoringParameters { -//! liquidity_penalty_multiplier_msat: 2 * 1000, -//! ..ProbabilisticScoringParameters::default() +//! let params = ProbabilisticScoringFeeParameters { +//! \tliquidity_penalty_multiplier_msat: 2 * 1000, +//! \t..ProbabilisticScoringFeeParameters::default() //! }; -//! let scorer = ProbabilisticScorer::new(params, &network_graph, &logger); +//! let decay_params = ProbabilisticScoringDecayParameters::default(); +//! let scorer = ProbabilisticScorer::new(decay_params, &network_graph, &logger); //! # let random_seed_bytes = [42u8; 32]; //! -//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer, &random_seed_bytes); +//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer, ¶ms, &random_seed_bytes); //! # } //! ``` //! @@ -77,8 +79,7 @@ pub struct Score { /// such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near /// [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. /// Thus, implementations should be overflow-safe. - #[must_use] - pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, usage: crate::lightning::routing::scoring::ChannelUsage) -> u64, + pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64, /// Handles updating channel penalties after failing to route through a channel. pub payment_path_failed: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, short_channel_id: u64), /// Handles updating channel penalties after successfully routing along a path. @@ -117,8 +118,8 @@ impl lightning::util::ser::Writeable for Score { use lightning::routing::scoring::Score as rustScore; impl rustScore for Score { - fn channel_penalty_msat(&self, mut short_channel_id: u64, mut source: &lightning::routing::gossip::NodeId, mut target: &lightning::routing::gossip::NodeId, mut usage: lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }); + fn channel_penalty_msat(&self, mut short_channel_id: u64, mut source: &lightning::routing::gossip::NodeId, mut target: &lightning::routing::gossip::NodeId, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }, &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((score_params as *const lightning::routing::scoring::ProbabilisticScoringFeeParameters<>) as *mut _) }, is_owned: false }); ret } fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64) { @@ -167,7 +168,6 @@ pub struct LockableScore { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the locked scorer. - #[must_use] pub lock: extern "C" fn (this_arg: *const c_void) -> crate::lightning::routing::scoring::Score, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -326,6 +326,77 @@ impl MultiThreadedLockableScore { ret } } +impl From for crate::lightning::routing::scoring::LockableScore { + fn from(obj: nativeMultiThreadedLockableScore) -> Self { + let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = MultiThreadedLockableScore_as_LockableScore(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(MultiThreadedLockableScore_free_void); + ret + } +} +/// Constructs a new LockableScore which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::LockableScore { + crate::lightning::routing::scoring::LockableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + lock: MultiThreadedLockableScore_LockableScore_lock, + } +} + +#[must_use] +extern "C" fn MultiThreadedLockableScore_LockableScore_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::Score { + let mut ret = >::lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); + Into::into(ret) +} + +#[no_mangle] +/// Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read +pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) }) +} +impl From for crate::lightning::routing::scoring::WriteableScore { + fn from(obj: nativeMultiThreadedLockableScore) -> Self { + let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = MultiThreadedLockableScore_as_WriteableScore(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(MultiThreadedLockableScore_free_void); + ret + } +} +/// Constructs a new WriteableScore which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_as_WriteableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::WriteableScore { + crate::lightning::routing::scoring::WriteableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + LockableScore: crate::lightning::routing::scoring::LockableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + lock: MultiThreadedLockableScore_LockableScore_lock, + }, + write: MultiThreadedLockableScore_write_void, + } +} + + +/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. +#[must_use] +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::routing::scoring::Score) -> crate::lightning::routing::scoring::MultiThreadedLockableScore { + let mut ret = lightning::routing::scoring::MultiThreadedLockableScore::new(score); + crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + use lightning::routing::scoring::MultiThreadedScoreLock as nativeMultiThreadedScoreLockImport; pub(crate) type nativeMultiThreadedScoreLock = nativeMultiThreadedScoreLockImport<'static, crate::lightning::routing::scoring::Score>; @@ -377,6 +448,15 @@ impl MultiThreadedScoreLock { ret } } +#[no_mangle] +/// Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read +pub extern "C" fn MultiThreadedScoreLock_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLock) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn MultiThreadedScoreLock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLock) }) +} impl From for crate::lightning::routing::scoring::Score { fn from(obj: nativeMultiThreadedScoreLock) -> Self { let mut rust_obj = MultiThreadedScoreLock { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -404,8 +484,8 @@ pub extern "C" fn MultiThreadedScoreLock_as_Score(this_arg: &MultiThreadedScoreL } #[must_use] -extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn MultiThreadedScoreLock_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -421,86 +501,6 @@ extern "C" fn MultiThreadedScoreLock_Score_probe_successful(this_arg: *mut c_voi >::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref()) } -#[no_mangle] -/// Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read -pub extern "C" fn MultiThreadedScoreLock_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLock) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn MultiThreadedScoreLock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLock) }) -} -impl From for crate::lightning::routing::scoring::LockableScore { - fn from(obj: nativeMultiThreadedLockableScore) -> Self { - let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = MultiThreadedLockableScore_as_LockableScore(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(MultiThreadedLockableScore_free_void); - ret - } -} -/// Constructs a new LockableScore which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::LockableScore { - crate::lightning::routing::scoring::LockableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - lock: MultiThreadedLockableScore_LockableScore_lock, - } -} - -#[must_use] -extern "C" fn MultiThreadedLockableScore_LockableScore_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::Score { - let mut ret = >::lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); - Into::into(ret) -} - -#[no_mangle] -/// Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read -pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) }) -} -impl From for crate::lightning::routing::scoring::WriteableScore { - fn from(obj: nativeMultiThreadedLockableScore) -> Self { - let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = MultiThreadedLockableScore_as_WriteableScore(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(MultiThreadedLockableScore_free_void); - ret - } -} -/// Constructs a new WriteableScore which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_as_WriteableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::WriteableScore { - crate::lightning::routing::scoring::WriteableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - LockableScore: crate::lightning::routing::scoring::LockableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - lock: MultiThreadedLockableScore_LockableScore_lock, - }, - write: MultiThreadedLockableScore_write_void, - } -} - - -/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. -#[must_use] -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::routing::scoring::Score) -> crate::lightning::routing::scoring::MultiThreadedLockableScore { - let mut ret = lightning::routing::scoring::MultiThreadedLockableScore::new(score); - crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - use lightning::routing::scoring::ChannelUsage as nativeChannelUsageImport; pub(crate) type nativeChannelUsage = nativeChannelUsageImport; @@ -721,8 +721,8 @@ pub extern "C" fn FixedPenaltyScorer_as_Score(this_arg: &FixedPenaltyScorer) -> } #[must_use] -extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -790,11 +790,11 @@ pub(crate) type nativeProbabilisticScorer = nativeProbabilisticScorerImport<&'st /// behavior. /// /// [1]: https://arxiv.org/abs/2107.05322 -/// [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat -/// [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat -/// [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life -/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat -/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat +/// [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_multiplier_msat +/// [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_amount_multiplier_msat +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life +/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_multiplier_msat +/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_amount_multiplier_msat #[must_use] #[repr(C)] pub struct ProbabilisticScorer { @@ -842,8 +842,8 @@ impl ProbabilisticScorer { } } -use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport; -pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport; +use lightning::routing::scoring::ProbabilisticScoringFeeParameters as nativeProbabilisticScoringFeeParametersImport; +pub(crate) type nativeProbabilisticScoringFeeParameters = nativeProbabilisticScoringFeeParametersImport; /// Parameters for configuring [`ProbabilisticScorer`]. /// @@ -854,12 +854,12 @@ pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScorin /// parameters here. #[must_use] #[repr(C)] -pub struct ProbabilisticScoringParameters { +pub struct ProbabilisticScoringFeeParameters { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeProbabilisticScoringParameters, + pub inner: *mut nativeProbabilisticScoringFeeParameters, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -867,31 +867,31 @@ pub struct ProbabilisticScoringParameters { pub is_owned: bool, } -impl Drop for ProbabilisticScoringParameters { +impl Drop for ProbabilisticScoringFeeParameters { fn drop(&mut self) { - if self.is_owned && !<*mut nativeProbabilisticScoringParameters>::is_null(self.inner) { + if self.is_owned && !<*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_free(this_obj: ProbabilisticScoringParameters) { } +pub extern "C" fn ProbabilisticScoringFeeParameters_free(this_obj: ProbabilisticScoringFeeParameters) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ProbabilisticScoringParameters_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringParameters) }; +pub(crate) extern "C" fn ProbabilisticScoringFeeParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringFeeParameters) }; } #[allow(unused)] -impl ProbabilisticScoringParameters { - pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringParameters { +impl ProbabilisticScoringFeeParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringFeeParameters { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringParameters { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringFeeParameters { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringFeeParameters { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -902,7 +902,7 @@ impl ProbabilisticScoringParameters { /// /// Default value: 500 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_base_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().base_penalty_msat; *inner_val } @@ -910,7 +910,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_msat(this_ptr: /// /// Default value: 500 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_base_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_penalty_msat = val; } /// A multiplier used with the payment amount to calculate a fixed penalty applied to each @@ -926,7 +926,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_msat(this_ptr: /// /// [`base_penalty_msat`]: Self::base_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().base_penalty_amount_multiplier_msat; *inner_val } @@ -943,7 +943,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_amount_multipl /// /// [`base_penalty_msat`]: Self::base_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_penalty_amount_multiplier_msat = val; } /// A multiplier used in conjunction with the negative `log10` of the channel's success @@ -961,9 +961,9 @@ pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_amount_multipl /// /// Default value: 30,000 msat /// -/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_multiplier_msat; *inner_val } @@ -982,58 +982,11 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplie /// /// Default value: 30,000 msat /// -/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_multiplier_msat = val; } -/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, -/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on -/// the available liquidity is halved and the upper-bound moves half-way to the channel's total -/// capacity. -/// -/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, -/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] -/// struct documentation for more info on the way the liquidity bounds are used. -/// -/// For example, if the channel's capacity is 1 million sats, and the current upper and lower -/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper -/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. -/// -/// Default value: 6 hours -/// -/// # Note -/// -/// When built with the `no-std` feature, time will never elapse. Therefore, the channel -/// liquidity knowledge will never decay except when the bounds cross. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_offset_half_life(this_ptr: &ProbabilisticScoringParameters) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_offset_half_life; - inner_val.as_secs() -} -/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, -/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on -/// the available liquidity is halved and the upper-bound moves half-way to the channel's total -/// capacity. -/// -/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, -/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] -/// struct documentation for more info on the way the liquidity bounds are used. -/// -/// For example, if the channel's capacity is 1 million sats, and the current upper and lower -/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper -/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. -/// -/// Default value: 6 hours -/// -/// # Note -/// -/// When built with the `no-std` feature, time will never elapse. Therefore, the channel -/// liquidity knowledge will never decay except when the bounds cross. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val); -} /// A multiplier used in conjunction with a payment amount and the negative `log10` of the /// channel's success probability for the payment, as determined by our latest estimates of the /// channel's liquidity, to determine the amount penalty. @@ -1053,7 +1006,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life( /// /// Default value: 192 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_amount_multiplier_msat; *inner_val } @@ -1076,7 +1029,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_amount_mu /// /// Default value: 192 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_amount_multiplier_msat = val; } /// A multiplier used in conjunction with the negative `log10` of the channel's success @@ -1094,7 +1047,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_amount_mu /// /// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_liquidity_penalty_multiplier_msat; *inner_val } @@ -1113,7 +1066,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalt /// /// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_liquidity_penalty_multiplier_msat = val; } /// A multiplier used in conjunction with the payment amount and the negative `log10` of the @@ -1135,7 +1088,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalt /// /// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_liquidity_penalty_amount_multiplier_msat; *inner_val } @@ -1158,53 +1111,30 @@ pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalt /// /// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_liquidity_penalty_amount_multiplier_msat = val; } -/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds -/// tracking can simply live on with increasingly stale data. Instead, when a channel has not -/// seen a liquidity estimate update for this amount of time, the historical datapoints are -/// decayed by half. -/// -/// Note that after 16 or more half lives all historical data will be completely gone. -/// -/// Default value: 14 days -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_no_updates_half_life(this_ptr: &ProbabilisticScoringParameters) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_no_updates_half_life; - inner_val.as_secs() -} -/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds -/// tracking can simply live on with increasingly stale data. Instead, when a channel has not -/// seen a liquidity estimate update for this amount of time, the historical datapoints are -/// decayed by half. -/// -/// Note that after 16 or more half lives all historical data will be completely gone. -/// -/// Default value: 14 days -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_no_updates_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_no_updates_half_life = core::time::Duration::from_secs(val); -} /// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the -/// channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We -/// treat such nodes preferentially as this makes balance discovery attacks harder to execute, -/// thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. +/// channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us +/// prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially +/// as this makes balance discovery attacks harder to execute, thereby creating an incentive +/// to restrict `htlc_maximum_msat` and improve privacy. /// /// Default value: 250 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_anti_probing_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().anti_probing_penalty_msat; *inner_val } /// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the -/// channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We -/// treat such nodes preferentially as this makes balance discovery attacks harder to execute, -/// thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. +/// channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us +/// prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially +/// as this makes balance discovery attacks harder to execute, thereby creating an incentive +/// to restrict `htlc_maximum_msat` and improve privacy. /// /// Default value: 250 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_anti_probing_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.anti_probing_penalty_msat = val; } /// This penalty is applied when the amount we're attempting to send over a channel exceeds our @@ -1225,7 +1155,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_anti_probing_penalty_msat(t /// [`base_penalty_msat`]: Self::base_penalty_msat /// [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().considered_impossible_penalty_msat; *inner_val } @@ -1247,13 +1177,219 @@ pub extern "C" fn ProbabilisticScoringParameters_get_considered_impossible_penal /// [`base_penalty_msat`]: Self::base_penalty_msat /// [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.considered_impossible_penalty_msat = val; } -impl Clone for ProbabilisticScoringParameters { +impl Clone for ProbabilisticScoringFeeParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbabilisticScoringFeeParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringFeeParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ProbabilisticScoringFeeParameters +pub extern "C" fn ProbabilisticScoringFeeParameters_clone(orig: &ProbabilisticScoringFeeParameters) -> ProbabilisticScoringFeeParameters { + orig.clone() +} +/// Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_default() -> ProbabilisticScoringFeeParameters { + ProbabilisticScoringFeeParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} +/// Marks the node with the given `node_id` as banned, +/// i.e it will be avoided during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_add_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.add_banned(node_id.get_native_ref()) +} + +/// Marks all nodes in the given list as banned, i.e., +/// they will be avoided during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_add_banned_from_list(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, mut node_ids: crate::c_types::derived::CVec_NodeIdZ) { + let mut local_node_ids = Vec::new(); for mut item in node_ids.into_rust().drain(..) { local_node_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.add_banned_from_list(local_node_ids) +} + +/// Removes the node with the given `node_id` from the list of nodes to avoid. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_remove_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.remove_banned(node_id.get_native_ref()) +} + +/// Sets a manual penalty for the given node. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_set_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId, mut penalty: u64) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.set_manual_penalty(node_id.get_native_ref(), penalty) +} + +/// Removes the node with the given `node_id` from the list of manual penalties. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_remove_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.remove_manual_penalty(node_id.get_native_ref()) +} + +/// Clears the list of manual penalties that are applied during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_clear_manual_penalties(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.clear_manual_penalties() +} + + +use lightning::routing::scoring::ProbabilisticScoringDecayParameters as nativeProbabilisticScoringDecayParametersImport; +pub(crate) type nativeProbabilisticScoringDecayParameters = nativeProbabilisticScoringDecayParametersImport; + +/// Parameters for configuring [`ProbabilisticScorer`]. +/// +/// Used to configure decay parameters that are static throughout the lifetime of the scorer. +/// these decay parameters affect the score of the channel penalty and are not changed on a +/// per-route penalty cost call. +#[must_use] +#[repr(C)] +pub struct ProbabilisticScoringDecayParameters { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeProbabilisticScoringDecayParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ProbabilisticScoringDecayParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_free(this_obj: ProbabilisticScoringDecayParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbabilisticScoringDecayParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringDecayParameters) }; +} +#[allow(unused)] +impl ProbabilisticScoringDecayParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringDecayParameters { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringDecayParameters { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringDecayParameters { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds +/// tracking can simply live on with increasingly stale data. Instead, when a channel has not +/// seen a liquidity estimate update for this amount of time, the historical datapoints are +/// decayed by half. +/// For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] +/// +/// Note that after 16 or more half lives all historical data will be completely gone. +/// +/// Default value: 14 days +/// +/// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(this_ptr: &ProbabilisticScoringDecayParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_no_updates_half_life; + inner_val.as_secs() +} +/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds +/// tracking can simply live on with increasingly stale data. Instead, when a channel has not +/// seen a liquidity estimate update for this amount of time, the historical datapoints are +/// decayed by half. +/// For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] +/// +/// Note that after 16 or more half lives all historical data will be completely gone. +/// +/// Default value: 14 days +/// +/// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(this_ptr: &mut ProbabilisticScoringDecayParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_no_updates_half_life = core::time::Duration::from_secs(val); +} +/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, +/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on +/// the available liquidity is halved and the upper-bound moves half-way to the channel's total +/// capacity. +/// +/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, +/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] +/// struct documentation for more info on the way the liquidity bounds are used. +/// +/// For example, if the channel's capacity is 1 million sats, and the current upper and lower +/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper +/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. +/// +/// Default value: 6 hours +/// +/// # Note +/// +/// When built with the `no-std` feature, time will never elapse. Therefore, the channel +/// liquidity knowledge will never decay except when the bounds cross. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(this_ptr: &ProbabilisticScoringDecayParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_offset_half_life; + inner_val.as_secs() +} +/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, +/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on +/// the available liquidity is halved and the upper-bound moves half-way to the channel's total +/// capacity. +/// +/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, +/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] +/// struct documentation for more info on the way the liquidity bounds are used. +/// +/// For example, if the channel's capacity is 1 million sats, and the current upper and lower +/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper +/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. +/// +/// Default value: 6 hours +/// +/// # Note +/// +/// When built with the `no-std` feature, time will never elapse. Therefore, the channel +/// liquidity knowledge will never decay except when the bounds cross. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringDecayParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val); +} +/// Constructs a new ProbabilisticScoringDecayParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_new(mut historical_no_updates_half_life_arg: u64, mut liquidity_offset_half_life_arg: u64) -> ProbabilisticScoringDecayParameters { + ProbabilisticScoringDecayParameters { inner: ObjOps::heap_alloc(nativeProbabilisticScoringDecayParameters { + historical_no_updates_half_life: core::time::Duration::from_secs(historical_no_updates_half_life_arg), + liquidity_offset_half_life: core::time::Duration::from_secs(liquidity_offset_half_life_arg), + }), is_owned: true } +} +impl Clone for ProbabilisticScoringDecayParameters { fn clone(&self) -> Self { Self { - inner: if <*mut nativeProbabilisticScoringParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1261,20 +1397,26 @@ impl Clone for ProbabilisticScoringParameters { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ProbabilisticScoringParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringParameters)).clone() })) as *mut c_void +pub(crate) extern "C" fn ProbabilisticScoringDecayParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringDecayParameters)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ProbabilisticScoringParameters -pub extern "C" fn ProbabilisticScoringParameters_clone(orig: &ProbabilisticScoringParameters) -> ProbabilisticScoringParameters { +/// Creates a copy of the ProbabilisticScoringDecayParameters +pub extern "C" fn ProbabilisticScoringDecayParameters_clone(orig: &ProbabilisticScoringDecayParameters) -> ProbabilisticScoringDecayParameters { orig.clone() } +/// Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_default() -> ProbabilisticScoringDecayParameters { + ProbabilisticScoringDecayParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} /// Creates a new scorer using the given scoring parameters for sending payments from a node /// through a network graph. #[must_use] #[no_mangle] -pub extern "C" fn ProbabilisticScorer_new(mut params: crate::lightning::routing::scoring::ProbabilisticScoringParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::scoring::ProbabilisticScorer { - let mut ret = lightning::routing::scoring::ProbabilisticScorer::new(*unsafe { Box::from_raw(params.take_inner()) }, network_graph.get_native_ref(), logger); +pub extern "C" fn ProbabilisticScorer_new(mut decay_params: crate::lightning::routing::scoring::ProbabilisticScoringDecayParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::scoring::ProbabilisticScorer { + let mut ret = lightning::routing::scoring::ProbabilisticScorer::new(*unsafe { Box::from_raw(decay_params.take_inner()) }, network_graph.get_native_ref(), logger); crate::lightning::routing::scoring::ProbabilisticScorer { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1326,51 +1468,6 @@ pub extern "C" fn ProbabilisticScorer_historical_estimated_channel_liquidity_pro local_ret } -/// Marks the node with the given `node_id` as banned, i.e., -/// it will be avoided during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_add_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.add_banned(node_id.get_native_ref()) -} - -/// Removes the node with the given `node_id` from the list of nodes to avoid. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_remove_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.remove_banned(node_id.get_native_ref()) -} - -/// Sets a manual penalty for the given node. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_set_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId, mut penalty: u64) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.set_manual_penalty(node_id.get_native_ref(), penalty) -} - -/// Removes the node with the given `node_id` from the list of manual penalties. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_remove_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.remove_manual_penalty(node_id.get_native_ref()) -} - -/// Clears the list of manual penalties that are applied during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_clear_manual_penalties(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.clear_manual_penalties() -} - -/// Marks all nodes in the given list as banned, i.e., -/// they will be avoided during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_add_banned_from_list(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringParameters, mut node_ids: crate::c_types::derived::CVec_NodeIdZ) { - let mut local_node_ids = Vec::new(); for mut item in node_ids.into_rust().drain(..) { local_node_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringParameters)) }.add_banned_from_list(local_node_ids) -} - -/// Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. -#[must_use] -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_default() -> ProbabilisticScoringParameters { - ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } -} impl From for crate::lightning::routing::scoring::Score { fn from(obj: nativeProbabilisticScorer) -> Self { let mut rust_obj = ProbabilisticScorer { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1398,8 +1495,8 @@ pub extern "C" fn ProbabilisticScorer_as_Score(this_arg: &ProbabilisticScorer) - } #[must_use] -extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn ProbabilisticScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -1437,7 +1534,7 @@ pub(crate) extern "C" fn ProbabilisticScorer_write_void(obj: *const c_void) -> c } #[no_mangle] /// Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write -pub extern "C" fn ProbabilisticScorer_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::routing::scoring::ProbabilisticScoringParameters, arg_b: &crate::lightning::routing::gossip::NetworkGraph, arg_c: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_ProbabilisticScorerDecodeErrorZ { +pub extern "C" fn ProbabilisticScorer_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::routing::scoring::ProbabilisticScoringDecayParameters, arg_b: &crate::lightning::routing::gossip::NetworkGraph, arg_c: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_ProbabilisticScorerDecodeErrorZ { let arg_a_conv = *unsafe { Box::from_raw(arg_a.take_inner()) }; let arg_b_conv = arg_b.get_native_ref(); let arg_c_conv = arg_c; diff --git a/lightning-c-bindings/src/lightning/routing/utxo.rs b/lightning-c-bindings/src/lightning/routing/utxo.rs index c9ed695..7f741e2 100644 --- a/lightning-c-bindings/src/lightning/routing/utxo.rs +++ b/lightning-c-bindings/src/lightning/routing/utxo.rs @@ -140,7 +140,7 @@ impl UtxoResult { match native { nativeUtxoResult::Sync (ref a, ) => { let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a_nonref, ) @@ -157,7 +157,7 @@ impl UtxoResult { pub(crate) fn native_into(native: nativeUtxoResult) -> Self { match native { nativeUtxoResult::Sync (mut a, ) => { - let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a, ) @@ -199,7 +199,6 @@ pub struct UtxoLookup { /// is unknown. /// /// [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id - #[must_use] pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::lightning::routing::utxo::UtxoResult, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. diff --git a/lightning-c-bindings/src/lightning/sign.rs b/lightning-c-bindings/src/lightning/sign.rs new file mode 100644 index 0000000..0ddfb51 --- /dev/null +++ b/lightning-c-bindings/src/lightning/sign.rs @@ -0,0 +1,2548 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Provides keys to LDK and defines some useful objects describing spendable on-chain outputs. +//! +//! The provided output descriptors follow a custom LDK data format and are currently not fully +//! compatible with Bitcoin Core output descriptors. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::sign::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport; +pub(crate) type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport; + +/// Information about a spendable output to a P2WSH script. +/// +/// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. +#[must_use] +#[repr(C)] +pub struct DelayedPaymentOutputDescriptor { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeDelayedPaymentOutputDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DelayedPaymentOutputDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor) }; +} +#[allow(unused)] +impl DelayedPaymentOutputDescriptor { + pub(crate) fn get_native_ref(&self) -> &'static nativeDelayedPaymentOutputDescriptor { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDelayedPaymentOutputDescriptor { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The outpoint which is spendable. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } +} +/// The outpoint which is spendable. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Per commitment point to derive the delayed payment key by key holder. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Per commitment point to derive the delayed payment key by key holder. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust(); +} +/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in +/// the witness_script. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in +/// the witness_script. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The output which is referenced by the given outpoint. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_output(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::TxOut { + let mut inner_val = &mut this_ptr.get_native_mut_ref().output; + crate::c_types::TxOut::from_rust(inner_val) +} +/// The output which is referenced by the given outpoint. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); +} +/// The revocation point specific to the commitment transaction which was broadcast. Used to +/// derive the witnessScript for this output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The revocation point specific to the commitment transaction which was broadcast. Used to +/// derive the witnessScript for this output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_pubkey = val.into_rust(); +} +/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. +/// This may be useful in re-deriving keys used in the channel to spend the output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; + inner_val +} +/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. +/// This may be useful in re-deriving keys used in the channel to spend the output. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; +} +/// The value of the channel which this output originated from, possibly indirectly. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; + *inner_val +} +/// The value of the channel which this output originated from, possibly indirectly. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; +} +/// Constructs a new DelayedPaymentOutputDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { + DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeDelayedPaymentOutputDescriptor { + outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, + per_commitment_point: per_commitment_point_arg.into_rust(), + to_self_delay: to_self_delay_arg, + output: output_arg.into_rust(), + revocation_pubkey: revocation_pubkey_arg.into_rust(), + channel_keys_id: channel_keys_id_arg.data, + channel_value_satoshis: channel_value_satoshis_arg, + }), is_owned: true } +} +impl Clone for DelayedPaymentOutputDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the DelayedPaymentOutputDescriptor +pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor { + orig.clone() +} +/// Checks if two DelayedPaymentOutputDescriptors 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. +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_eq(a: &DelayedPaymentOutputDescriptor, b: &DelayedPaymentOutputDescriptor) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read +pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::sign::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentOutputDescriptor) }) +} +#[no_mangle] +/// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write +pub extern "C" fn DelayedPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::sign::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport; +pub(crate) type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport; + +/// Information about a spendable output to our \"payment key\". +/// +/// See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. +#[must_use] +#[repr(C)] +pub struct StaticPaymentOutputDescriptor { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeStaticPaymentOutputDescriptor, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for StaticPaymentOutputDescriptor { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor) }; +} +#[allow(unused)] +impl StaticPaymentOutputDescriptor { + pub(crate) fn get_native_ref(&self) -> &'static nativeStaticPaymentOutputDescriptor { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStaticPaymentOutputDescriptor { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The outpoint which is spendable. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } +} +/// The outpoint which is spendable. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The output which is referenced by the given outpoint. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_output(this_ptr: &StaticPaymentOutputDescriptor) -> crate::c_types::TxOut { + let mut inner_val = &mut this_ptr.get_native_mut_ref().output; + crate::c_types::TxOut::from_rust(inner_val) +} +/// The output which is referenced by the given outpoint. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); +} +/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. +/// This may be useful in re-deriving keys used in the channel to spend the output. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; + inner_val +} +/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. +/// This may be useful in re-deriving keys used in the channel to spend the output. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; +} +/// The value of the channel which this transactions spends. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; + *inner_val +} +/// The value of the channel which this transactions spends. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; +} +/// Constructs a new StaticPaymentOutputDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor { + StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeStaticPaymentOutputDescriptor { + outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, + output: output_arg.into_rust(), + channel_keys_id: channel_keys_id_arg.data, + channel_value_satoshis: channel_value_satoshis_arg, + }), is_owned: true } +} +impl Clone for StaticPaymentOutputDescriptor { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the StaticPaymentOutputDescriptor +pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor { + orig.clone() +} +/// Checks if two StaticPaymentOutputDescriptors 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. +#[no_mangle] +pub extern "C" fn StaticPaymentOutputDescriptor_eq(a: &StaticPaymentOutputDescriptor, b: &StaticPaymentOutputDescriptor) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read +pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn StaticPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStaticPaymentOutputDescriptor) }) +} +#[no_mangle] +/// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write +pub extern "C" fn StaticPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Describes the necessary information to spend a spendable output. +/// +/// When on-chain outputs are created by LDK (which our counterparty is not able to claim at any +/// point in the future) a [`SpendableOutputs`] event is generated which you must track and be able +/// to spend on-chain. The information needed to do this is provided in this enum, including the +/// outpoint describing which `txid` and output `index` is available, the full output which exists +/// at that `txid`/`index`, and any keys or other information required to sign. +/// +/// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum SpendableOutputDescriptor { + /// An output to a script which was provided via [`SignerProvider`] directly, either from + /// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already + /// know how to spend it. No secret keys are provided as LDK was never given any key. + /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC + /// on-chain using the payment preimage or after it has timed out. + /// + /// [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey + /// [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey + StaticOutput { + /// The outpoint which is spendable. + outpoint: crate::lightning::chain::transaction::OutPoint, + /// The output which is referenced by the given outpoint. + output: crate::c_types::TxOut, + }, + /// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` + /// delay. + /// + /// The witness in the spending input should be: + /// ```bitcoin + /// (MINIMALIF standard rule) + /// ``` + /// + /// Note that the `nSequence` field in the spending input must be set to + /// [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not + /// broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after + /// the outpoint confirms, see [BIP + /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK + /// won't generate a [`SpendableOutputDescriptor`] until the corresponding block height + /// is reached. + /// + /// These are generally the result of a \"revocable\" output to us, spendable only by us unless + /// it is an output from an old state which we broadcast (which should never happen). + /// + /// To derive the delayed payment key which is used to sign this input, you must pass the + /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the + /// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided + /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be + /// generated without the secret key using [`chan_utils::derive_public_key`] and only the + /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. + /// + /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is + /// used in the witness script generation), you must pass the counterparty + /// [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to + /// [`ChannelSigner::provide_channel_parameters`]) and the provided + /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to + /// [`chan_utils::derive_public_revocation_key`]. + /// + /// The witness script which is hashed and included in the output `script_pubkey` may be + /// regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived + /// as explained above), our delayed payment pubkey (derived as explained above), and the + /// [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to + /// [`chan_utils::get_revokeable_redeemscript`]. + DelayedPaymentOutput( + crate::lightning::sign::DelayedPaymentOutputDescriptor), + /// An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key + /// which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness + /// in the spending input is, thus, simply: + /// ```bitcoin + /// + /// ``` + /// + /// These are generally the result of our counterparty having broadcast the current state, + /// allowing us to claim the non-HTLC-encumbered outputs immediately. + StaticPaymentOutput( + crate::lightning::sign::StaticPaymentOutputDescriptor), +} +use lightning::sign::SpendableOutputDescriptor as SpendableOutputDescriptorImport; +pub(crate) type nativeSpendableOutputDescriptor = SpendableOutputDescriptorImport; + +impl SpendableOutputDescriptor { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeSpendableOutputDescriptor { + match self { + SpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + let mut output_nonref = Clone::clone(output); + nativeSpendableOutputDescriptor::StaticOutput { + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, + output: output_nonref.into_rust(), + } + }, + SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeSpendableOutputDescriptor::DelayedPaymentOutput ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeSpendableOutputDescriptor::StaticPaymentOutput ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeSpendableOutputDescriptor { + match self { + SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { + nativeSpendableOutputDescriptor::StaticOutput { + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, + output: output.into_rust(), + } + }, + SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { + nativeSpendableOutputDescriptor::DelayedPaymentOutput ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { + nativeSpendableOutputDescriptor::StaticPaymentOutput ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeSpendableOutputDescriptor) -> Self { + match native { + nativeSpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + let mut output_nonref = Clone::clone(output); + SpendableOutputDescriptor::StaticOutput { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, + output: crate::c_types::TxOut::from_rust(&output_nonref), + } + }, + nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { + let mut a_nonref = Clone::clone(a); + SpendableOutputDescriptor::DelayedPaymentOutput ( + crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { + let mut a_nonref = Clone::clone(a); + SpendableOutputDescriptor::StaticPaymentOutput ( + crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self { + match native { + nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { + SpendableOutputDescriptor::StaticOutput { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, + output: crate::c_types::TxOut::from_rust(&output), + } + }, + nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { + SpendableOutputDescriptor::DelayedPaymentOutput ( + crate::lightning::sign::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { + SpendableOutputDescriptor::StaticPaymentOutput ( + crate::lightning::sign::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the SpendableOutputDescriptor +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { } +/// Creates a copy of the SpendableOutputDescriptor +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor +pub extern "C" fn SpendableOutputDescriptor_static_output(outpoint: crate::lightning::chain::transaction::OutPoint, output: crate::c_types::TxOut) -> SpendableOutputDescriptor { + SpendableOutputDescriptor::StaticOutput { + outpoint, + output, + } +} +#[no_mangle] +/// Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor +pub extern "C" fn SpendableOutputDescriptor_delayed_payment_output(a: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> SpendableOutputDescriptor { + SpendableOutputDescriptor::DelayedPaymentOutput(a, ) +} +#[no_mangle] +/// Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor +pub extern "C" fn SpendableOutputDescriptor_static_payment_output(a: crate::lightning::sign::StaticPaymentOutputDescriptor) -> SpendableOutputDescriptor { + SpendableOutputDescriptor::StaticPaymentOutput(a, ) +} +/// Checks if two SpendableOutputDescriptors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_eq(a: &SpendableOutputDescriptor, b: &SpendableOutputDescriptor) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read +pub extern "C" fn SpendableOutputDescriptor_write(obj: &crate::lightning::sign::SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write +pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to +/// the given outputs, plus an output to the given change destination (if sufficient +/// change value remains). The PSBT will have a feerate, at least, of the given value. +/// +/// The `locktime` argument is used to set the transaction's locktime. If `None`, the +/// transaction will have a locktime of 0. It it recommended to set this to the current block +/// height to avoid fee sniping, unless you have some specific reason to use a different +/// locktime. +/// +/// Returns the PSBT and expected max transaction weight. +/// +/// Returns `Err(())` if the output value is greater than the input value minus required fee, +/// if a descriptor was duplicated, or if an output descriptor `script_pubkey` +/// does not match the one we can spend. +/// +/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. +#[must_use] +#[no_mangle] +pub extern "C" fn SpendableOutputDescriptor_create_spendable_outputs_psbt(mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_PackedLockTimeZ) -> crate::c_types::derived::CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} }; + let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (::bitcoin::consensus::encode::serialize(&orig_ret_0_0).into(), orig_ret_0_1).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// A trait to handle Lightning channel key material without concretizing the channel type or +/// the signature mechanism. +#[repr(C)] +pub struct ChannelSigner { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Gets the per-commitment point for a specific commitment number + /// + /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey, + /// Gets the commitment secret for a specific commitment number as part of the revocation process + /// + /// An external signer implementation should error here if the commitment was already signed + /// and should refuse to sign it in the future. + /// + /// May be called more than once for the same index. + /// + /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, + /// Validate the counterparty's signatures on the holder commitment transaction and HTLCs. + /// + /// This is required in order for the signer to make sure that releasing a commitment + /// secret won't leave us without a broadcastable holder transaction. + /// Policy checks should be implemented in this function, including checking the amount + /// sent to us and checking the HTLCs. + /// + /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + /// A validating signer should ensure that an HTLC output is removed only when the matching + /// preimage is provided, or when the value to holder is restored. + /// + /// Note that all the relevant preimages will be provided, but there may also be additional + /// irrelevant or duplicate preimages. + pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ, + /// Returns the holder's channel public keys and basepoints. + pub pubkeys: core::cell::UnsafeCell, + /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns + /// Note that this takes a pointer to this object, not the this_ptr like other methods do + /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. + pub set_pubkeys: Option, + /// Returns an arbitrary identifier describing the set of keys which are provided back to you in + /// some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this + /// [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. + pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Set the counterparty static channel data, including basepoints, + /// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. + /// + /// This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] + /// instance, LDK will call this method exactly once - either immediately after construction + /// (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding + /// information has been generated. + /// + /// channel_parameters.is_populated() MUST be true. + pub provide_channel_parameters: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters), + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for ChannelSigner {} +unsafe impl Sync for ChannelSigner {} +#[no_mangle] +pub(crate) extern "C" fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner { + ChannelSigner { + this_arg: orig.this_arg, + get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point), + release_commitment_secret: Clone::clone(&orig.release_commitment_secret), + validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment), + pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(), + set_pubkeys: Clone::clone(&orig.set_pubkeys), + channel_keys_id: Clone::clone(&orig.channel_keys_id), + provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::ChannelSigner as rustChannelSigner; +impl rustChannelSigner for ChannelSigner { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { + let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); + ret.into_rust() + } + fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + let mut ret = (self.release_commitment_secret)(self.this_arg, idx); + ret.data + } + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { + let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.validate_holder_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.set_pubkeys { + (f)(&self); + } + unsafe { &*self.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.channel_keys_id)(self.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.provide_channel_parameters)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for ChannelSigner { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn ChannelSigner_free(this_ptr: ChannelSigner) { } +impl Drop for ChannelSigner { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait to sign Lightning channel transactions as described in +/// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). +/// +/// Signing services could be implemented on a hardware wallet and should implement signing +/// policies in order to be secure. Please refer to the [VLS Policy +/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) +/// for an example of such policies. +#[repr(C)] +pub struct EcdsaChannelSigner { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. + /// + /// Note that if signing fails or is rejected, the channel will be force-closed. + /// + /// Policy checks should be implemented in this function, including checking the amount + /// sent to us and checking the HTLCs. + /// + /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. + /// A validating signer should ensure that an HTLC output is removed only when the matching + /// preimage is provided, or when the value to holder is restored. + /// + /// Note that all the relevant preimages will be provided, but there may also be additional + /// irrelevant or duplicate preimages. + pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + /// Validate the counterparty's revocation. + /// + /// This is required in order for the signer to make sure that the state has moved + /// forward and it is safe to sign the next counterparty commitment. + pub validate_counterparty_revocation: extern "C" fn (this_arg: *const c_void, idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ, + /// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. + /// + /// This will be called + /// - with a non-revoked `commitment_tx`. + /// - with the latest `commitment_tx` when we initiate a force-close. + /// - with the previous `commitment_tx`, just to get claiming HTLC + /// signatures, if we are reacting to a [`ChannelMonitor`] + /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) + /// that decided to broadcast before it had been updated to the latest `commitment_tx`. + /// + /// This may be called multiple times for the same transaction. + /// + /// An external signer implementation should check that the commitment has not been revoked. + /// + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + /// Create a signature for the given input in a transaction spending an HTLC transaction output + /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state. + /// + /// A justice transaction may claim multiple outputs at the same time if timelocks are + /// similar, but only a signature for the input at index `input` should be signed for here. + /// It may be called multiple times for same output(s) if a fee-bump is needed with regards + /// to an upcoming timelock expiration. + /// + /// Amount is value of the output spent by this input, committed to in the BIP 143 signature. + /// + /// `per_commitment_key` is revocation secret which was provided by our counterparty when they + /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do + /// so). + pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Create a signature for the given input in a transaction spending a commitment transaction + /// HTLC output when our counterparty broadcasts an old state. + /// + /// A justice transaction may claim multiple outputs at the same time if timelocks are + /// similar, but only a signature for the input at index `input` should be signed for here. + /// It may be called multiple times for same output(s) if a fee-bump is needed with regards + /// to an upcoming timelock expiration. + /// + /// `amount` is the value of the output spent by this input, committed to in the BIP 143 + /// signature. + /// + /// `per_commitment_key` is revocation secret which was provided by our counterparty when they + /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does + /// not allow the spending of any funds by itself (you need our holder revocation_secret to do + /// so). + /// + /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script + /// (which is committed to in the BIP 143 signatures). + pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Computes the signature for a commitment transaction's HTLC output used as an input within + /// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned + /// must be be computed using [`EcdsaSighashType::All`]. Note that this should only be used to + /// sign HTLC transactions from channels supporting anchor outputs after all additional + /// inputs/outputs have been added to the transaction. + /// + /// [`EcdsaSighashType::All`]: bitcoin::blockdata::transaction::EcdsaSighashType::All + pub sign_holder_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, htlc_descriptor: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment + /// transaction, either offered or received. + /// + /// Such a transaction may claim multiples offered outputs at same time if we know the + /// preimage for each when we create it, but only the input at index `input` should be + /// signed for here. It may be called multiple times for same output(s) if a fee-bump is + /// needed with regards to an upcoming timelock expiration. + /// + /// `witness_script` is either an offered or received script as defined in BOLT3 for HTLC + /// outputs. + /// + /// `amount` is value of the output spent by this input, committed to in the BIP 143 signature. + /// + /// `per_commitment_point` is the dynamic point corresponding to the channel state + /// detected onchain. It has been generated by our counterparty and is used to derive + /// channel state keys, which are then included in the witness script and committed to in the + /// BIP 143 signature. + pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Create a signature for a (proposed) closing transaction. + /// + /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have + /// chosen to forgo their output as dust. + pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Computes the signature for a commitment transaction's anchor output used as an + /// input within `anchor_tx`, which spends the commitment transaction, at index `input`. + pub sign_holder_anchor_input: extern "C" fn (this_arg: *const c_void, anchor_tx: crate::c_types::Transaction, input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Signs a channel announcement message with our funding key proving it comes from one of the + /// channel participants. + /// + /// Channel announcements also require a signature from each node's network key. Our node + /// signature is computed through [`NodeSigner::sign_gossip_message`]. + /// + /// Note that if this fails or is rejected, the channel will not be publicly announced and + /// our counterparty may (though likely will not) close the channel on us for violating the + /// protocol. + pub sign_channel_announcement_with_funding_key: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Implementation of ChannelSigner for this object. + pub ChannelSigner: crate::lightning::sign::ChannelSigner, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for EcdsaChannelSigner {} +unsafe impl Sync for EcdsaChannelSigner {} +#[no_mangle] +pub(crate) extern "C" fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner { + EcdsaChannelSigner { + this_arg: orig.this_arg, + sign_counterparty_commitment: Clone::clone(&orig.sign_counterparty_commitment), + validate_counterparty_revocation: Clone::clone(&orig.validate_counterparty_revocation), + sign_holder_commitment_and_htlcs: Clone::clone(&orig.sign_holder_commitment_and_htlcs), + sign_justice_revoked_output: Clone::clone(&orig.sign_justice_revoked_output), + sign_justice_revoked_htlc: Clone::clone(&orig.sign_justice_revoked_htlc), + sign_holder_htlc_transaction: Clone::clone(&orig.sign_holder_htlc_transaction), + sign_counterparty_htlc_transaction: Clone::clone(&orig.sign_counterparty_htlc_transaction), + sign_closing_transaction: Clone::clone(&orig.sign_closing_transaction), + sign_holder_anchor_input: Clone::clone(&orig.sign_holder_anchor_input), + sign_channel_announcement_with_funding_key: Clone::clone(&orig.sign_channel_announcement_with_funding_key), + ChannelSigner: crate::lightning::sign::ChannelSigner_clone_fields(&orig.ChannelSigner), + free: Clone::clone(&orig.free), + } +} +impl lightning::sign::ChannelSigner for EcdsaChannelSigner { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { + let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx); + ret.into_rust() + } + fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx); + ret.data + } + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { + let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.ChannelSigner.validate_holder_commitment)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.ChannelSigner.set_pubkeys { + (f)(&self.ChannelSigner); + } + unsafe { &*self.ChannelSigner.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.ChannelSigner.channel_keys_id)(self.ChannelSigner.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.ChannelSigner.provide_channel_parameters)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) + } +} + +use lightning::sign::EcdsaChannelSigner as rustEcdsaChannelSigner; +impl rustEcdsaChannelSigner for EcdsaChannelSigner { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.validate_counterparty_revocation)(self.this_arg, idx, secret.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::events::bump_transaction::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_holder_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::events::bump_transaction::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::events::bump_transaction::HTLCDescriptor<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_closing_transaction)(self.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_holder_anchor_input)(self.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.sign_channel_announcement_with_funding_key)(self.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for EcdsaChannelSigner { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { } +impl Drop for EcdsaChannelSigner { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A writeable signer. +/// +/// There will always be two instances of a signer per channel, one occupied by the +/// [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor +#[repr(C)] +pub struct WriteableEcdsaChannelSigner { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Implementation of EcdsaChannelSigner for this object. + pub EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner, + /// Serialize the object into a byte array + pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for WriteableEcdsaChannelSigner {} +unsafe impl Sync for WriteableEcdsaChannelSigner {} +#[no_mangle] +pub(crate) extern "C" fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { + WriteableEcdsaChannelSigner { + this_arg: orig.this_arg, + EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner), + write: Clone::clone(&orig.write), + free: Clone::clone(&orig.free), + } +} +impl lightning::sign::EcdsaChannelSigner for WriteableEcdsaChannelSigner { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.EcdsaChannelSigner.sign_counterparty_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.EcdsaChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.this_arg, idx, secret.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment_and_htlcs)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_output)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_htlc)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::events::bump_transaction::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_holder_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::events::bump_transaction::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::events::bump_transaction::HTLCDescriptor<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_counterparty_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_closing_transaction)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_holder_anchor_input)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.EcdsaChannelSigner.sign_channel_announcement_with_funding_key)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} +impl lightning::sign::ChannelSigner for WriteableEcdsaChannelSigner { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { + let mut ret = (self.EcdsaChannelSigner.ChannelSigner.get_per_commitment_point)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); + ret.into_rust() + } + fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + let mut ret = (self.EcdsaChannelSigner.ChannelSigner.release_commitment_secret)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); + ret.data + } + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { + let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_holder_commitment)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys { + (f)(&self.EcdsaChannelSigner.ChannelSigner); + } + unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.EcdsaChannelSigner.ChannelSigner.provide_channel_parameters)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) + } +} +impl lightning::util::ser::Writeable for WriteableEcdsaChannelSigner { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.write)(self.this_arg); + w.write_all(vec.as_slice()) + } +} + +use lightning::sign::WriteableEcdsaChannelSigner as rustWriteableEcdsaChannelSigner; +impl rustWriteableEcdsaChannelSigner for WriteableEcdsaChannelSigner { +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for WriteableEcdsaChannelSigner { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { } +impl Drop for WriteableEcdsaChannelSigner { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// Specifies the recipient of an invoice. +/// +/// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign +/// the invoice. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Recipient { + /// The invoice should be signed with the local node secret key. + Node, + /// The invoice should be signed with the phantom node secret key. This secret key must be the + /// same for all nodes participating in the [phantom node payment]. + /// + /// [phantom node payment]: PhantomKeysManager + PhantomNode, +} +use lightning::sign::Recipient as RecipientImport; +pub(crate) type nativeRecipient = RecipientImport; + +impl Recipient { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeRecipient { + match self { + Recipient::Node => nativeRecipient::Node, + Recipient::PhantomNode => nativeRecipient::PhantomNode, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeRecipient { + match self { + Recipient::Node => nativeRecipient::Node, + Recipient::PhantomNode => nativeRecipient::PhantomNode, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeRecipient) -> Self { + match native { + nativeRecipient::Node => Recipient::Node, + nativeRecipient::PhantomNode => Recipient::PhantomNode, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeRecipient) -> Self { + match native { + nativeRecipient::Node => Recipient::Node, + nativeRecipient::PhantomNode => Recipient::PhantomNode, + } + } +} +/// Creates a copy of the Recipient +#[no_mangle] +pub extern "C" fn Recipient_clone(orig: &Recipient) -> Recipient { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new Node-variant Recipient +pub extern "C" fn Recipient_node() -> Recipient { + Recipient::Node} +#[no_mangle] +/// Utility method to constructs a new PhantomNode-variant Recipient +pub extern "C" fn Recipient_phantom_node() -> Recipient { + Recipient::PhantomNode} +/// A trait that describes a source of entropy. +#[repr(C)] +pub struct EntropySource { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Gets a unique, cryptographically-secure, random 32-byte value. This method must return a + /// different value each time it is called. + pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for EntropySource {} +unsafe impl Sync for EntropySource {} +#[no_mangle] +pub(crate) extern "C" fn EntropySource_clone_fields(orig: &EntropySource) -> EntropySource { + EntropySource { + this_arg: orig.this_arg, + get_secure_random_bytes: Clone::clone(&orig.get_secure_random_bytes), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::EntropySource as rustEntropySource; +impl rustEntropySource for EntropySource { + fn get_secure_random_bytes(&self) -> [u8; 32] { + let mut ret = (self.get_secure_random_bytes)(self.this_arg); + ret.data + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for EntropySource { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn EntropySource_free(this_ptr: EntropySource) { } +impl Drop for EntropySource { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait that can handle cryptographic operations at the scope level of a node. +#[repr(C)] +pub struct NodeSigner { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Get secret key material as bytes for use in encrypting and decrypting inbound payment data. + /// + /// If the implementor of this trait supports [phantom node payments], then every node that is + /// intended to be included in the phantom invoice route hints must return the same value from + /// this method. + /// + /// This method must return the same value each time it is called. + /// + /// [phantom node payments]: PhantomKeysManager + pub get_inbound_payment_key_material: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, + /// Get node id based on the provided [`Recipient`]. + /// + /// This method must return the same value each time it is called with a given [`Recipient`] + /// parameter. + /// + /// Errors if the [`Recipient`] variant is not supported by the implementation. + pub get_node_id: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ, + /// Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if + /// one is provided. Note that this tweak can be applied to `other_key` instead of our node + /// secret, though this is less efficient. + /// + /// Note that if this fails while attempting to forward an HTLC, LDK will panic. The error + /// should be resolved to allow LDK to resume forwarding HTLCs. + /// + /// Errors if the [`Recipient`] variant is not supported by the implementation. + pub ecdh: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::sign::Recipient, other_key: crate::c_types::PublicKey, tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ, + /// Sign an invoice. + /// + /// By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of + /// this trait to parse the invoice and make sure they're signing what they expect, rather than + /// blindly signing the hash. + /// + /// The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. + /// + /// The secret key used to sign the invoice is dependent on the [`Recipient`]. + /// + /// Errors if the [`Recipient`] variant is not supported by the implementation. + pub sign_invoice: extern "C" fn (this_arg: *const c_void, hrp_bytes: crate::c_types::u8slice, invoice_data: crate::c_types::derived::CVec_U5Z, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, + /// Sign a gossip message. + /// + /// Note that if this fails, LDK may panic and the message will not be broadcast to the network + /// or a possible channel counterparty. If LDK panics, the error should be resolved to allow the + /// message to be broadcast, as otherwise it may prevent one from receiving funds over the + /// corresponding channel. + pub sign_gossip_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for NodeSigner {} +unsafe impl Sync for NodeSigner {} +#[no_mangle] +pub(crate) extern "C" fn NodeSigner_clone_fields(orig: &NodeSigner) -> NodeSigner { + NodeSigner { + this_arg: orig.this_arg, + get_inbound_payment_key_material: Clone::clone(&orig.get_inbound_payment_key_material), + get_node_id: Clone::clone(&orig.get_node_id), + ecdh: Clone::clone(&orig.ecdh), + sign_invoice: Clone::clone(&orig.sign_invoice), + sign_gossip_message: Clone::clone(&orig.sign_gossip_message), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::NodeSigner as rustNodeSigner; +impl rustNodeSigner for NodeSigner { + fn get_inbound_payment_key_material(&self) -> lightning::sign::KeyMaterial { + let mut ret = (self.get_inbound_payment_key_material)(self.this_arg); + ::lightning::sign::KeyMaterial(ret.data) + } + fn get_node_id(&self, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.get_node_id)(self.this_arg, crate::lightning::sign::Recipient::native_into(recipient)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn ecdh(&self, mut recipient: lightning::sign::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result { + let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) }; + let mut ret = (self.ecdh)(self.this_arg, crate::lightning::sign::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut recipient: lightning::sign::Recipient) -> Result { + let mut local_hrp_bytes = crate::c_types::u8slice::from_slice(hrp_bytes); + let mut local_invoice_data_clone = Vec::new(); local_invoice_data_clone.extend_from_slice(invoice_data); let mut invoice_data = local_invoice_data_clone; let mut local_invoice_data = Vec::new(); for mut item in invoice_data.drain(..) { local_invoice_data.push( { item.into() }); }; + let mut ret = (self.sign_invoice)(self.this_arg, local_hrp_bytes, local_invoice_data.into(), crate::lightning::sign::Recipient::native_into(recipient)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result { + let mut ret = (self.sign_gossip_message)(self.this_arg, crate::lightning::ln::msgs::UnsignedGossipMessage::native_into(msg)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for NodeSigner { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn NodeSigner_free(this_ptr: NodeSigner) { } +impl Drop for NodeSigner { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// A trait that can return signer instances for individual channels. +#[repr(C)] +pub struct SignerProvider { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through + /// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow + /// implementations of [`SignerProvider`] to maintain a mapping between itself and the generated + /// `channel_keys_id`. + /// + /// This method must return a different value each time it is called. + pub generate_channel_keys_id: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64, user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes, + /// Derives the private key material backing a `Signer`. + /// + /// To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through + /// [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be + /// re-derived from its `channel_keys_id`, which can be obtained through its trait method + /// [`ChannelSigner::channel_keys_id`]. + pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner, + /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. + /// This is only called during deserialization of other objects which contain + /// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + /// The bytes are exactly those which `::write()` writes, and + /// contain no versioning scheme. You may wish to include your own version prefix and ensure + /// you've read all of the provided bytes to ensure no corruption occurred. + /// + /// This method is slowly being phased out -- it will only be called when reading objects + /// written by LDK versions prior to 0.0.113. + /// + /// [`Signer`]: Self::Signer + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ, + /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + /// + /// If this function returns an error, this will result in a channel failing to open. + /// + /// This method should return a different value each time it is called, to avoid linking + /// on-chain funds across channels as controlled to the same user. + pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_ScriptNoneZ, + /// Get a script pubkey which we will send funds to when closing a channel. + /// + /// If this function returns an error, this will result in a channel failing to open or close. + /// In the event of a failure when the counterparty is initiating a close, this can result in a + /// channel force close. + /// + /// This method should return a different value each time it is called, to avoid linking + /// on-chain funds across channels as controlled to the same user. + pub get_shutdown_scriptpubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for SignerProvider {} +unsafe impl Sync for SignerProvider {} +#[no_mangle] +pub(crate) extern "C" fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvider { + SignerProvider { + this_arg: orig.this_arg, + generate_channel_keys_id: Clone::clone(&orig.generate_channel_keys_id), + derive_channel_signer: Clone::clone(&orig.derive_channel_signer), + read_chan_signer: Clone::clone(&orig.read_chan_signer), + get_destination_script: Clone::clone(&orig.get_destination_script), + get_shutdown_scriptpubkey: Clone::clone(&orig.get_shutdown_scriptpubkey), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::SignerProvider as rustSignerProvider; +impl rustSignerProvider for SignerProvider { + type Signer = crate::lightning::sign::WriteableEcdsaChannelSigner; + fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] { + let mut ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id.into()); + ret.data + } + fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + let mut ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); + ret + } + fn read_chan_signer(&self, mut reader: &[u8]) -> Result { + let mut local_reader = crate::c_types::u8slice::from_slice(reader); + let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn get_destination_script(&self) -> Result { + let mut ret = (self.get_destination_script)(self.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::Script::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn get_shutdown_scriptpubkey(&self) -> Result { + let mut ret = (self.get_shutdown_scriptpubkey)(self.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for SignerProvider { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn SignerProvider_free(this_ptr: SignerProvider) { } +impl Drop for SignerProvider { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} + +use lightning::sign::InMemorySigner as nativeInMemorySignerImport; +pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport; + +/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. +/// +/// This implementation performs no policy checks and is insufficient by itself as +/// a secure external signer. +#[must_use] +#[repr(C)] +pub struct InMemorySigner { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInMemorySigner, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for InMemorySigner { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInMemorySigner) }; +} +#[allow(unused)] +impl InMemorySigner { + pub(crate) fn get_native_ref(&self) -> &'static nativeInMemorySigner { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInMemorySigner { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the +/// holder's anchor output in a commitment transaction, if one is present. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_key; + inner_val.as_ref() +} +/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the +/// holder's anchor output in a commitment transaction, if one is present. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_key = val.into_rust(); +} +/// Holder secret key for blinded revocation pubkey. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_base_key; + inner_val.as_ref() +} +/// Holder secret key for blinded revocation pubkey. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_base_key = val.into_rust(); +} +/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_key; + inner_val.as_ref() +} +/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_key = val.into_rust(); +} +/// Holder secret key used in an HTLC transaction. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_base_key; + inner_val.as_ref() +} +/// Holder secret key used in an HTLC transaction. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_base_key = val.into_rust(); +} +/// Holder HTLC secret key used in commitment transaction HTLC outputs. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_base_key; + inner_val.as_ref() +} +/// Holder HTLC secret key used in commitment transaction HTLC outputs. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_base_key = val.into_rust(); +} +/// Commitment seed. +#[no_mangle] +pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_seed; + inner_val +} +/// Commitment seed. +#[no_mangle] +pub extern "C" fn InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_seed = val.data; +} +impl Clone for InMemorySigner { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InMemorySigner +pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { + orig.clone() +} +/// Creates a new [`InMemorySigner`]. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes, mut rand_bytes_unique_start: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::InMemorySigner { + let mut ret = lightning::sign::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data, rand_bytes_unique_start.data); + crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the counterparty's pubkeys. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_pubkeys(); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } +} + +/// Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable +/// transactions, i.e., the amount of time that we have to wait to recover our funds if we +/// broadcast a transaction. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &crate::lightning::sign::InMemorySigner) -> u16 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_selected_contest_delay(); + ret +} + +/// Returns the `contest_delay` value specified by us and applied on transactions broadcastable +/// by our counterparty, i.e., the amount of time that they have to wait to recover their funds +/// if they broadcast a transaction. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &crate::lightning::sign::InMemorySigner) -> u16 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.holder_selected_contest_delay(); + ret +} + +/// Returns whether the holder is the initiator. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_is_outbound(this_arg: &crate::lightning::sign::InMemorySigner) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_outbound(); + ret +} + +/// Funding outpoint +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::chain::transaction::OutPoint { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint(); + crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } +} + +/// Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or +/// building transactions. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_channel_parameters(); + crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false } +} + +/// Returns the channel type features of the channel parameters. Should be helpful for +/// determining a channel's category, i. e. legacy/anchors/taproot/etc. +/// +/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } +} + +/// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described +/// by `descriptor`, returning the witness stack for the input. +/// +/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, +/// is not spending the outpoint described by [`descriptor.outpoint`], +/// or if an output descriptor `script_pubkey` does not match the one we can spend. +/// +/// [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &crate::lightning::sign::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::sign::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sign the single input of `spend_tx` at index `input_idx` which spends the output +/// described by `descriptor`, returning the witness stack for the input. +/// +/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, +/// is not spending the outpoint described by [`descriptor.outpoint`], does not have a +/// sequence set to [`descriptor.to_self_delay`], or if an output descriptor +/// `script_pubkey` does not match the one we can spend. +/// +/// [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint +/// [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay +#[must_use] +#[no_mangle] +pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &crate::lightning::sign::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::sign::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::sign::EntropySource { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = InMemorySigner_as_EntropySource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(InMemorySigner_free_void); + ret + } +} +/// Constructs a new EntropySource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> crate::lightning::sign::EntropySource { + crate::lightning::sign::EntropySource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_secure_random_bytes: InMemorySigner_EntropySource_get_secure_random_bytes, + } +} + +#[must_use] +extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +impl From for crate::lightning::sign::ChannelSigner { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = InMemorySigner_as_ChannelSigner(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(InMemorySigner_free_void); + ret + } +} +/// Constructs a new ChannelSigner which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::ChannelSigner { + crate::lightning::sign::ChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, + release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, + validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), + set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), + channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, + provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, + } +} + +#[must_use] +extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { + let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1); + crate::c_types::PublicKey::from_rust(&ret) +} +#[must_use] +extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn InMemorySigner_ChannelSigner_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; + let mut ret = >::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_preimages); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { + let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } +} +extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) { + // This is a bit race-y in the general case, but for our specific use-cases today, we're safe + // Specifically, we must ensure that the first time we're called it can never be in parallel + if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() { + *unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); + } +} +#[must_use] +extern "C" fn InMemorySigner_ChannelSigner_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} +extern "C" fn InMemorySigner_ChannelSigner_provide_channel_parameters(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { + >::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref()) +} + +impl From for crate::lightning::sign::EcdsaChannelSigner { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = InMemorySigner_as_EcdsaChannelSigner(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(InMemorySigner_free_void); + ret + } +} +/// Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::EcdsaChannelSigner { + crate::lightning::sign::EcdsaChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, + validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, + sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, + sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, + sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, + sign_holder_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, + sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, + sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, + ChannelSigner: crate::lightning::sign::ChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, + release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, + validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), + set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), + channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, + provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, + }, + } +} + +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; + let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_preimages, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = >::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + let mut ret = >::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, htlc_descriptor: &crate::lightning::events::bump_transaction::HTLCDescriptor) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_holder_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, htlc_descriptor.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input(this_arg: *const c_void, mut anchor_tx: crate::c_types::Transaction, mut input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::sign::WriteableEcdsaChannelSigner { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(InMemorySigner_free_void); + ret + } +} +/// Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + crate::lightning::sign::WriteableEcdsaChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + EcdsaChannelSigner: crate::lightning::sign::EcdsaChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, + validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, + sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, + sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, + sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, + sign_holder_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction, + sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, + sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, + sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, + sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, + ChannelSigner: crate::lightning::sign::ChannelSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, + release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, + validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, + + pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), + set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), + channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, + provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, + }, + }, + write: InMemorySigner_write_void, + } +} + + +#[no_mangle] +/// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read +pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::sign::InMemorySigner) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) +} +#[no_mangle] +/// Read a InMemorySigner from a byte array, created by InMemorySigner_write +pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { + let arg_conv = arg; + let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::sign::KeysManager as nativeKeysManagerImport; +pub(crate) type nativeKeysManager = nativeKeysManagerImport; + +/// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a +/// 32-byte seed for use as a BIP 32 extended key and derives keys from that. +/// +/// Your `node_id` is seed/0'. +/// Unilateral closes may use seed/1'. +/// Cooperative closes may use seed/2'. +/// The two close keys may be needed to claim on-chain funds! +/// +/// This struct cannot be used for nodes that wish to support receiving phantom payments; +/// [`PhantomKeysManager`] must be used instead. +/// +/// Note that switching between this struct and [`PhantomKeysManager`] will invalidate any +/// previously issued invoices and attempts to pay previous invoices will fail. +#[must_use] +#[repr(C)] +pub struct KeysManager { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeKeysManager, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for KeysManager { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn KeysManager_free(this_obj: KeysManager) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeKeysManager) }; +} +#[allow(unused)] +impl KeysManager { + pub(crate) fn get_native_ref(&self) -> &'static nativeKeysManager { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeKeysManager { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., +/// your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). +/// `starting_time` isn't strictly required to actually be a time, but it must absolutely, +/// without a doubt, be unique to this instance. ie if you start multiple times with the same +/// `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this +/// is to simply use the current time (with very high precision). +/// +/// The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, +/// obviously, `starting_time` should be unique every time you reload the library - it is only +/// used to generate new ephemeral key data (which will be stored by the individual channel if +/// necessary). +/// +/// Note that the seed is required to recover certain on-chain funds independent of +/// [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required +/// for any channel, and some on-chain during-closing funds. +/// +/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> crate::lightning::sign::KeysManager { + let mut ret = lightning::sign::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos); + crate::lightning::sign::KeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::sign::KeysManager) -> crate::c_types::SecretKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); + crate::c_types::SecretKey::from_rust(ret) +} + +/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::sign::KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::sign::InMemorySigner { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); + crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s. +/// The resulting inputs will be finalized and the PSBT will be ready for broadcast if there +/// are no other inputs that need signing. +/// +/// Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. +/// +/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used +/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_sign_spendable_outputs_psbt(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_PartiallySignedTransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], ::bitcoin::consensus::encode::deserialize(psbt.as_slice()).expect("Invalid PSBT format"), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { ::bitcoin::consensus::encode::serialize(&o).into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an +/// output to the given change destination (if sufficient change value remains). The +/// transaction will have a feerate, at least, of the given value. +/// +/// The `locktime` argument is used to set the transaction's locktime. If `None`, the +/// transaction will have a locktime of 0. It it recommended to set this to the current block +/// height to avoid fee sniping, unless you have some specific reason to use a different +/// locktime. +/// +/// Returns `Err(())` if the output value is greater than the input value minus required fee, +/// if a descriptor was duplicated, or if an output descriptor `script_pubkey` +/// does not match the one we can spend. +/// +/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. +/// +/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used +/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. +#[must_use] +#[no_mangle] +pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_PackedLockTimeZ) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::sign::EntropySource { + fn from(obj: nativeKeysManager) -> Self { + let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = KeysManager_as_EntropySource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(KeysManager_free_void); + ret + } +} +/// Constructs a new EntropySource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn KeysManager_as_EntropySource(this_arg: &KeysManager) -> crate::lightning::sign::EntropySource { + crate::lightning::sign::EntropySource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_secure_random_bytes: KeysManager_EntropySource_get_secure_random_bytes, + } +} + +#[must_use] +extern "C" fn KeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +impl From for crate::lightning::sign::NodeSigner { + fn from(obj: nativeKeysManager) -> Self { + let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = KeysManager_as_NodeSigner(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(KeysManager_free_void); + ret + } +} +/// Constructs a new NodeSigner which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is +#[no_mangle] +pub extern "C" fn KeysManager_as_NodeSigner(this_arg: &KeysManager) -> crate::lightning::sign::NodeSigner { + crate::lightning::sign::NodeSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_inbound_payment_key_material: KeysManager_NodeSigner_get_inbound_payment_key_material, + get_node_id: KeysManager_NodeSigner_get_node_id, + ecdh: KeysManager_NodeSigner_ecdh, + sign_invoice: KeysManager_NodeSigner_sign_invoice, + sign_gossip_message: KeysManager_NodeSigner_sign_gossip_message, + } +} + +#[must_use] +extern "C" fn KeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + crate::c_types::ThirtyTwoBytes { data: ret.0 } +} +#[must_use] +extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { + let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { + let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); + let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; + let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn KeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::sign::SignerProvider { + fn from(obj: nativeKeysManager) -> Self { + let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = KeysManager_as_SignerProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(KeysManager_free_void); + ret + } +} +/// Constructs a new SignerProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn KeysManager_as_SignerProvider(this_arg: &KeysManager) -> crate::lightning::sign::SignerProvider { + crate::lightning::sign::SignerProvider { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + generate_channel_keys_id: KeysManager_SignerProvider_generate_channel_keys_id, + derive_channel_signer: KeysManager_SignerProvider_derive_channel_signer, + read_chan_signer: KeysManager_SignerProvider_read_chan_signer, + get_destination_script: KeysManager_SignerProvider_get_destination_script, + get_shutdown_scriptpubkey: KeysManager_SignerProvider_get_shutdown_scriptpubkey, + } +} + +#[must_use] +extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data); + Into::into(ret) +} +#[must_use] +extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_ret +} +#[must_use] +extern "C" fn KeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CResult_ScriptNoneZ { + let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn KeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ { + let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::sign::PhantomKeysManager as nativePhantomKeysManagerImport; +pub(crate) type nativePhantomKeysManager = nativePhantomKeysManagerImport; + +/// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node +/// payments. +/// +/// A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be +/// paid to one of multiple nodes. This works because we encode the invoice route hints such that +/// LDK will recognize an incoming payment as destined for a phantom node, and collect the payment +/// itself without ever needing to forward to this fake node. +/// +/// Phantom node payments are useful for load balancing between multiple LDK nodes. They also +/// provide some fault tolerance, because payers will automatically retry paying other provided +/// nodes in the case that one node goes down. +/// +/// Note that multi-path payments are not supported in phantom invoices for security reasons. +/// Switching between this struct and [`KeysManager`] will invalidate any previously issued +/// invoices and attempts to pay previous invoices will fail. +#[must_use] +#[repr(C)] +pub struct PhantomKeysManager { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePhantomKeysManager, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for PhantomKeysManager { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PhantomKeysManager_free(this_obj: PhantomKeysManager) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PhantomKeysManager_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomKeysManager) }; +} +#[allow(unused)] +impl PhantomKeysManager { + pub(crate) fn get_native_ref(&self) -> &'static nativePhantomKeysManager { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomKeysManager { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativePhantomKeysManager { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl From for crate::lightning::sign::EntropySource { + fn from(obj: nativePhantomKeysManager) -> Self { + let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = PhantomKeysManager_as_EntropySource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(PhantomKeysManager_free_void); + ret + } +} +/// Constructs a new EntropySource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn PhantomKeysManager_as_EntropySource(this_arg: &PhantomKeysManager) -> crate::lightning::sign::EntropySource { + crate::lightning::sign::EntropySource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_secure_random_bytes: PhantomKeysManager_EntropySource_get_secure_random_bytes, + } +} + +#[must_use] +extern "C" fn PhantomKeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +impl From for crate::lightning::sign::NodeSigner { + fn from(obj: nativePhantomKeysManager) -> Self { + let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = PhantomKeysManager_as_NodeSigner(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(PhantomKeysManager_free_void); + ret + } +} +/// Constructs a new NodeSigner which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is +#[no_mangle] +pub extern "C" fn PhantomKeysManager_as_NodeSigner(this_arg: &PhantomKeysManager) -> crate::lightning::sign::NodeSigner { + crate::lightning::sign::NodeSigner { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_inbound_payment_key_material: PhantomKeysManager_NodeSigner_get_inbound_payment_key_material, + get_node_id: PhantomKeysManager_NodeSigner_get_node_id, + ecdh: PhantomKeysManager_NodeSigner_ecdh, + sign_invoice: PhantomKeysManager_NodeSigner_sign_invoice, + sign_gossip_message: PhantomKeysManager_NodeSigner_sign_gossip_message, + } +} + +#[must_use] +extern "C" fn PhantomKeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + crate::c_types::ThirtyTwoBytes { data: ret.0 } +} +#[must_use] +extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { + let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { + let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); + let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; + let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { + let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +impl From for crate::lightning::sign::SignerProvider { + fn from(obj: nativePhantomKeysManager) -> Self { + let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = PhantomKeysManager_as_SignerProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(PhantomKeysManager_free_void); + ret + } +} +/// Constructs a new SignerProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn PhantomKeysManager_as_SignerProvider(this_arg: &PhantomKeysManager) -> crate::lightning::sign::SignerProvider { + crate::lightning::sign::SignerProvider { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + generate_channel_keys_id: PhantomKeysManager_SignerProvider_generate_channel_keys_id, + derive_channel_signer: PhantomKeysManager_SignerProvider_derive_channel_signer, + read_chan_signer: PhantomKeysManager_SignerProvider_read_chan_signer, + get_destination_script: PhantomKeysManager_SignerProvider_get_destination_script, + get_shutdown_scriptpubkey: PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey, + } +} + +#[must_use] +extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); + crate::c_types::ThirtyTwoBytes { data: ret } +} +#[must_use] +extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::WriteableEcdsaChannelSigner { + let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data); + Into::into(ret) +} +#[must_use] +extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CResult_ScriptNoneZ { + let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ { + let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` +/// that is shared across all nodes that intend to participate in [phantom node payments] +/// together. +/// +/// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and +/// `starting_time_nanos`. +/// +/// `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the +/// same across restarts, or else inbound payments may fail. +/// +/// [phantom node payments]: PhantomKeysManager +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomKeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32, cross_node_seed: *const [u8; 32]) -> crate::lightning::sign::PhantomKeysManager { + let mut ret = lightning::sign::PhantomKeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos, unsafe { &*cross_node_seed}); + crate::lightning::sign::PhantomKeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// See [`KeysManager::spend_spendable_outputs`] for documentation on this method. +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomKeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::PhantomKeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_PackedLockTimeZ) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::PackedLockTime({ locktime_opt.take() }) }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// See [`KeysManager::derive_channel_keys`] for documentation on this method. +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomKeysManager_derive_channel_keys(this_arg: &crate::lightning::sign::PhantomKeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::sign::InMemorySigner { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); + crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomKeysManager_get_node_secret_key(this_arg: &crate::lightning::sign::PhantomKeysManager) -> crate::c_types::SecretKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); + crate::c_types::SecretKey::from_rust(ret) +} + +/// Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the +/// last-hop onion data, etc. +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomKeysManager_get_phantom_node_secret_key(this_arg: &crate::lightning::sign::PhantomKeysManager) -> crate::c_types::SecretKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_node_secret_key(); + crate::c_types::SecretKey::from_rust(ret) +} + diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index 13e65a4..e451b42 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -312,7 +312,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut Ch /// /// Default value: true. /// -/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey +/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelHandshakeConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey; @@ -330,7 +330,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this /// /// Default value: true. /// -/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey +/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val; @@ -388,6 +388,71 @@ pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_ pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val; } +/// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future +/// channels. This feature requires having a reserve of onchain funds readily available to bump +/// transactions in the event of a channel force close to avoid the possibility of losing funds. +/// +/// Note that if you wish accept inbound channels with anchor outputs, you must enable +/// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with +/// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check +/// whether your reserve of onchain funds is enough to cover the fees for all existing and new +/// channels featuring anchor outputs in the event of a force close. +/// +/// If this option is set, channels may be created that will not be readable by LDK versions +/// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a +/// [`DecodeError::InvalidValue`]. +/// +/// Note that setting this to true does *not* prevent us from opening channels with +/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply +/// fall back to a `static_remote_key` channel. +/// +/// LDK will not support the legacy `option_anchors` commitment version due to a discovered +/// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee +/// Considered Harmful`] mailing list post. +/// +/// Default value: false. This value is likely to change to true in the future. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue +/// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &ChannelHandshakeConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().negotiate_anchors_zero_fee_htlc_tx; + *inner_val +} +/// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future +/// channels. This feature requires having a reserve of onchain funds readily available to bump +/// transactions in the event of a channel force close to avoid the possibility of losing funds. +/// +/// Note that if you wish accept inbound channels with anchor outputs, you must enable +/// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with +/// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check +/// whether your reserve of onchain funds is enough to cover the fees for all existing and new +/// channels featuring anchor outputs in the event of a force close. +/// +/// If this option is set, channels may be created that will not be readable by LDK versions +/// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a +/// [`DecodeError::InvalidValue`]. +/// +/// Note that setting this to true does *not* prevent us from opening channels with +/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply +/// fall back to a `static_remote_key` channel. +/// +/// LDK will not support the legacy `option_anchors` commitment version due to a discovered +/// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee +/// Considered Harmful`] mailing list post. +/// +/// Default value: false. This value is likely to change to true in the future. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue +/// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.negotiate_anchors_zero_fee_htlc_tx = val; +} /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time. /// /// Increasing the value can help improve liquidity and stability in @@ -422,7 +487,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &m /// Constructs a new ChannelHandshakeConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { +pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut negotiate_anchors_zero_fee_htlc_tx_arg: bool, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig { minimum_depth: minimum_depth_arg, our_to_self_delay: our_to_self_delay_arg, @@ -432,6 +497,7 @@ pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our announced_channel: announced_channel_arg, commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg, + negotiate_anchors_zero_fee_htlc_tx: negotiate_anchors_zero_fee_htlc_tx_arg, our_max_accepted_htlcs: our_max_accepted_htlcs_arg, }), is_owned: true } } @@ -779,6 +845,158 @@ pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits { ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } } +/// Options for how to set the max dust HTLC exposure allowed on a channel. See +/// [`ChannelConfig::max_dust_htlc_exposure`] for details. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MaxDustHTLCExposure { + /// This sets a fixed limit on the total dust exposure in millisatoshis. Setting this too low + /// may prevent the sending or receipt of low-value HTLCs on high-traffic nodes, however this + /// limit is very important to prevent stealing of large amounts of dust HTLCs by miners + /// through [fee griefing + /// attacks](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html). + /// + /// Note that if the feerate increases significantly, without a manual increase + /// to this maximum the channel may be unable to send/receive HTLCs between the maximum dust + /// exposure and the new minimum value for HTLCs to be economically viable to claim. + FixedLimitMsat( + u64), + /// This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from + /// [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used + /// then the maximum dust exposure in millisatoshis is calculated as: + /// `high_priority_feerate_per_kw * value`. For example, with our default value + /// `FeeRateMultiplier(5000)`: + /// + /// - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum + /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + /// be 253 * 5000 = 1,265,000 msats. + /// - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be + /// 7500 * 5000 = 37,500,000 msats. + /// + /// This allows the maximum dust exposure to automatically scale with fee rate changes. + /// + /// Note, if you're using a third-party fee estimator, this may leave you more exposed to a + /// fee griefing attack, where your fee estimator may purposely overestimate the fee rate, + /// causing you to accept more dust HTLCs than you would otherwise. + /// + /// This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included + /// on HTLC outputs means your channel may be subject to more dust exposure in the event of + /// increases in fee rate. + /// + /// # Backwards Compatibility + /// This variant only became available in LDK 0.0.116, so if you downgrade to a prior version + /// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + FeeRateMultiplier( + u64), +} +use lightning::util::config::MaxDustHTLCExposure as MaxDustHTLCExposureImport; +pub(crate) type nativeMaxDustHTLCExposure = MaxDustHTLCExposureImport; + +impl MaxDustHTLCExposure { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMaxDustHTLCExposure { + match self { + MaxDustHTLCExposure::FixedLimitMsat (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMaxDustHTLCExposure::FixedLimitMsat ( + a_nonref, + ) + }, + MaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMaxDustHTLCExposure::FeeRateMultiplier ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMaxDustHTLCExposure { + match self { + MaxDustHTLCExposure::FixedLimitMsat (mut a, ) => { + nativeMaxDustHTLCExposure::FixedLimitMsat ( + a, + ) + }, + MaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => { + nativeMaxDustHTLCExposure::FeeRateMultiplier ( + a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeMaxDustHTLCExposure) -> Self { + match native { + nativeMaxDustHTLCExposure::FixedLimitMsat (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MaxDustHTLCExposure::FixedLimitMsat ( + a_nonref, + ) + }, + nativeMaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MaxDustHTLCExposure::FeeRateMultiplier ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMaxDustHTLCExposure) -> Self { + match native { + nativeMaxDustHTLCExposure::FixedLimitMsat (mut a, ) => { + MaxDustHTLCExposure::FixedLimitMsat ( + a, + ) + }, + nativeMaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => { + MaxDustHTLCExposure::FeeRateMultiplier ( + a, + ) + }, + } + } +} +/// Frees any resources used by the MaxDustHTLCExposure +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_free(this_ptr: MaxDustHTLCExposure) { } +/// Creates a copy of the MaxDustHTLCExposure +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_clone(orig: &MaxDustHTLCExposure) -> MaxDustHTLCExposure { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure +pub extern "C" fn MaxDustHTLCExposure_fixed_limit_msat(a: u64) -> MaxDustHTLCExposure { + MaxDustHTLCExposure::FixedLimitMsat(a, ) +} +#[no_mangle] +/// Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure +pub extern "C" fn MaxDustHTLCExposure_fee_rate_multiplier(a: u64) -> MaxDustHTLCExposure { + MaxDustHTLCExposure::FeeRateMultiplier(a, ) +} +/// Checks if two MaxDustHTLCExposures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_eq(a: &MaxDustHTLCExposure, b: &MaxDustHTLCExposure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read +pub extern "C" fn MaxDustHTLCExposure_write(obj: &crate::lightning::util::config::MaxDustHTLCExposure) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write +pub extern "C" fn MaxDustHTLCExposure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_MaxDustHTLCExposureDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::util::config::ChannelConfig as nativeChannelConfigImport; pub(crate) type nativeChannelConfig = nativeChannelConfigImport; @@ -945,18 +1163,18 @@ pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConf /// channel negotiated throughout the channel open process, along with the fees required to have /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into -/// account the HTLC transaction fee as it is zero. +/// account the HTLC transaction fee as it is zero. Because of this, you may want to set this +/// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier +/// variant is primarily intended for use with pre-anchor channels. /// -/// This limit is applied for sent, forwarded, and received HTLCs and limits the total -/// exposure across all three types per-channel. Setting this too low may prevent the -/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very -/// important to prevent stealing of dust HTLCs by miners. +/// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total +/// exposure across all three types per-channel. /// -/// Default value: 5_000_000 msat. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. #[no_mangle] -pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat; - *inner_val +pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelConfig) -> crate::lightning::util::config::MaxDustHTLCExposure { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure; + crate::lightning::util::config::MaxDustHTLCExposure::from_native(inner_val) } /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too /// small to claim on-chain. @@ -971,17 +1189,17 @@ pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &Chann /// channel negotiated throughout the channel open process, along with the fees required to have /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into -/// account the HTLC transaction fee as it is zero. +/// account the HTLC transaction fee as it is zero. Because of this, you may want to set this +/// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier +/// variant is primarily intended for use with pre-anchor channels. /// -/// This limit is applied for sent, forwarded, and received HTLCs and limits the total -/// exposure across all three types per-channel. Setting this too low may prevent the -/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very -/// important to prevent stealing of dust HTLCs by miners. +/// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total +/// exposure across all three types per-channel. /// -/// Default value: 5_000_000 msat. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. #[no_mangle] -pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = val; +pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut ChannelConfig, mut val: crate::lightning::util::config::MaxDustHTLCExposure) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure = val.into_native(); } /// The additional fee we're willing to pay to avoid waiting for the counterparty's /// `to_self_delay` to reclaim funds. @@ -1036,16 +1254,84 @@ pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val; } +/// If set, allows this channel's counterparty to skim an additional fee off this node's inbound +/// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. +/// +/// Usage: +/// - The payee will set this option and set its invoice route hints to use [intercept scids] +/// generated by this channel's counterparty. +/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call +/// [`forward_intercepted_htlc`] with less than the amount provided in +/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and +/// actual forward amounts is their fee. +/// +/// # Note +/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is +/// as-expected if this feature is activated, otherwise they may lose money! +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the +/// counterparty. +/// +/// # Note +/// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. +/// Unsetting this flag between restarts may lead to payment receive failures. +/// +/// Default value: false. +/// +/// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid +/// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc +/// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat +/// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat +#[no_mangle] +pub extern "C" fn ChannelConfig_get_accept_underpaying_htlcs(this_ptr: &ChannelConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_underpaying_htlcs; + *inner_val +} +/// If set, allows this channel's counterparty to skim an additional fee off this node's inbound +/// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. +/// +/// Usage: +/// - The payee will set this option and set its invoice route hints to use [intercept scids] +/// generated by this channel's counterparty. +/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call +/// [`forward_intercepted_htlc`] with less than the amount provided in +/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and +/// actual forward amounts is their fee. +/// +/// # Note +/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is +/// as-expected if this feature is activated, otherwise they may lose money! +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the +/// counterparty. +/// +/// # Note +/// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. +/// Unsetting this flag between restarts may lead to payment receive failures. +/// +/// Default value: false. +/// +/// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid +/// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc +/// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat +/// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat +#[no_mangle] +pub extern "C" fn ChannelConfig_set_accept_underpaying_htlcs(this_ptr: &mut ChannelConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_underpaying_htlcs = val; +} /// Constructs a new ChannelConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_arg: u32, mut forwarding_fee_base_msat_arg: u32, mut cltv_expiry_delta_arg: u16, mut max_dust_htlc_exposure_msat_arg: u64, mut force_close_avoidance_max_fee_satoshis_arg: u64) -> ChannelConfig { +pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_arg: u32, mut forwarding_fee_base_msat_arg: u32, mut cltv_expiry_delta_arg: u16, mut max_dust_htlc_exposure_arg: crate::lightning::util::config::MaxDustHTLCExposure, mut force_close_avoidance_max_fee_satoshis_arg: u64, mut accept_underpaying_htlcs_arg: bool) -> ChannelConfig { ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig { forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat: forwarding_fee_base_msat_arg, cltv_expiry_delta: cltv_expiry_delta_arg, - max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg, + max_dust_htlc_exposure: max_dust_htlc_exposure_arg.into_native(), force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg, + accept_underpaying_htlcs: accept_underpaying_htlcs_arg, }), is_owned: true } } impl Clone for ChannelConfig { @@ -1076,6 +1362,12 @@ pub extern "C" fn ChannelConfig_eq(a: &ChannelConfig, b: &ChannelConfig) -> bool if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`]. +#[no_mangle] +pub extern "C" fn ChannelConfig_apply(this_arg: &mut crate::lightning::util::config::ChannelConfig, update: &crate::lightning::util::config::ChannelConfigUpdate) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::util::config::nativeChannelConfig)) }.apply(update.get_native_ref()) +} + /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. #[must_use] #[no_mangle] @@ -1099,6 +1391,137 @@ pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_t local_res } +use lightning::util::config::ChannelConfigUpdate as nativeChannelConfigUpdateImport; +pub(crate) type nativeChannelConfigUpdate = nativeChannelConfigUpdateImport; + +/// A parallel struct to [`ChannelConfig`] to define partial updates. +#[must_use] +#[repr(C)] +pub struct ChannelConfigUpdate { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelConfigUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelConfigUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelConfigUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelConfigUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_free(this_obj: ChannelConfigUpdate) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelConfigUpdate_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfigUpdate) }; +} +#[allow(unused)] +impl ChannelConfigUpdate { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfigUpdate { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfigUpdate { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfigUpdate { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_base_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_cltv_expiry_delta(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u16Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_cltv_expiry_delta(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u16Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = local_val; +} +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_MaxDustHTLCExposureZ { + let mut inner_val = this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_MaxDustHTLCExposureZ::None } else { crate::c_types::derived::COption_MaxDustHTLCExposureZ::Some( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_MaxDustHTLCExposureZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = local_val; +} +/// Constructs a new ChannelConfigUpdate given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_new(mut forwarding_fee_proportional_millionths_arg: crate::c_types::derived::COption_u32Z, mut forwarding_fee_base_msat_arg: crate::c_types::derived::COption_u32Z, mut cltv_expiry_delta_arg: crate::c_types::derived::COption_u16Z, mut max_dust_htlc_exposure_msat_arg: crate::c_types::derived::COption_MaxDustHTLCExposureZ, mut force_close_avoidance_max_fee_satoshis_arg: crate::c_types::derived::COption_u64Z) -> ChannelConfigUpdate { + let mut local_forwarding_fee_proportional_millionths_arg = if forwarding_fee_proportional_millionths_arg.is_some() { Some( { forwarding_fee_proportional_millionths_arg.take() }) } else { None }; + let mut local_forwarding_fee_base_msat_arg = if forwarding_fee_base_msat_arg.is_some() { Some( { forwarding_fee_base_msat_arg.take() }) } else { None }; + let mut local_cltv_expiry_delta_arg = if cltv_expiry_delta_arg.is_some() { Some( { cltv_expiry_delta_arg.take() }) } else { None }; + let mut local_max_dust_htlc_exposure_msat_arg = { /*max_dust_htlc_exposure_msat_arg*/ let max_dust_htlc_exposure_msat_arg_opt = max_dust_htlc_exposure_msat_arg; if max_dust_htlc_exposure_msat_arg_opt.is_none() { None } else { Some({ { { max_dust_htlc_exposure_msat_arg_opt.take() }.into_native() }})} }; + let mut local_force_close_avoidance_max_fee_satoshis_arg = if force_close_avoidance_max_fee_satoshis_arg.is_some() { Some( { force_close_avoidance_max_fee_satoshis_arg.take() }) } else { None }; + ChannelConfigUpdate { inner: ObjOps::heap_alloc(nativeChannelConfigUpdate { + forwarding_fee_proportional_millionths: local_forwarding_fee_proportional_millionths_arg, + forwarding_fee_base_msat: local_forwarding_fee_base_msat_arg, + cltv_expiry_delta: local_cltv_expiry_delta_arg, + max_dust_htlc_exposure_msat: local_max_dust_htlc_exposure_msat_arg, + force_close_avoidance_max_fee_satoshis: local_force_close_avoidance_max_fee_satoshis_arg, + }), is_owned: true } +} +/// Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_default() -> ChannelConfigUpdate { + ChannelConfigUpdate { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} + use lightning::util::config::UserConfig as nativeUserConfigImport; pub(crate) type nativeUserConfig = nativeUserConfigImport; @@ -1303,10 +1726,39 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val; } +/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to true, we'll accept the payment. +/// +/// Setting this to true will break backwards compatibility upon downgrading to an LDK +/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. +/// +/// Default value: false. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +#[no_mangle] +pub extern "C" fn UserConfig_get_accept_mpp_keysend(this_ptr: &UserConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_mpp_keysend; + *inner_val +} +/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to true, we'll accept the payment. +/// +/// Setting this to true will break backwards compatibility upon downgrading to an LDK +/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. +/// +/// Default value: false. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +#[no_mangle] +pub extern "C" fn UserConfig_set_accept_mpp_keysend(this_ptr: &mut UserConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_mpp_keysend = val; +} /// Constructs a new UserConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool) -> UserConfig { +pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool, mut accept_mpp_keysend_arg: bool) -> UserConfig { UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig { channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) }, channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) }, @@ -1315,6 +1767,7 @@ pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightn accept_inbound_channels: accept_inbound_channels_arg, manually_accept_inbound_channels: manually_accept_inbound_channels_arg, accept_intercept_htlcs: accept_intercept_htlcs_arg, + accept_mpp_keysend: accept_mpp_keysend_arg, }), is_owned: true } } impl Clone for UserConfig { diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs index ff0f416..7ca7891 100644 --- a/lightning-c-bindings/src/lightning/util/errors.rs +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -65,7 +65,7 @@ pub enum APIError { /// Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open /// a channel or cooperatively close one with this peer (and will have to force-close instead). /// - /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey /// [`InitFeatures`]: crate::ln::features::InitFeatures IncompatibleShutdownScript { /// The incompatible shutdown script. diff --git a/lightning-c-bindings/src/lightning/util/persist.rs b/lightning-c-bindings/src/lightning/util/persist.rs index 5aae5c6..0c77f8d 100644 --- a/lightning-c-bindings/src/lightning/util/persist.rs +++ b/lightning-c-bindings/src/lightning/util/persist.rs @@ -25,13 +25,10 @@ pub struct Persister { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. - #[must_use] pub persist_manager: extern "C" fn (this_arg: *const c_void, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NoneErrorZ, /// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. - #[must_use] pub persist_graph: extern "C" fn (this_arg: *const c_void, network_graph: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ, /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. - #[must_use] pub persist_scorer: extern "C" fn (this_arg: *const c_void, scorer: &crate::lightning::routing::scoring::WriteableScore) -> crate::c_types::derived::CResult_NoneErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -51,8 +48,8 @@ pub(crate) extern "C" fn Persister_clone_fields(orig: &Persister) -> Persister { } use lightning::util::persist::Persister as rustPersister; -impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::EntropySource, crate::lightning::chain::keysinterface::NodeSigner, crate::lightning::chain::keysinterface::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister { - fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { +impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister { + fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { let mut ret = (self.persist_manager)(self.this_arg, &crate::lightning::ln::channelmanager::ChannelManager { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_manager as *const lightning::ln::channelmanager::ChannelManager<_, _, _, _, _, _, _, _, >) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; local_ret diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index 824dc7a..193a22c 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -98,6 +98,60 @@ pub extern "C" fn BigSize_new(mut a_arg: u64) -> BigSize { a_arg, )), is_owned: true } } +impl Clone for BigSize { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBigSize>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BigSize_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBigSize)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BigSize +pub extern "C" fn BigSize_clone(orig: &BigSize) -> BigSize { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the BigSize. +#[no_mangle] +pub extern "C" fn BigSize_hash(o: &BigSize) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BigSizes 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. +#[no_mangle] +pub extern "C" fn BigSize_eq(a: &BigSize, b: &BigSize) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the BigSize object into a byte array which can be read by BigSize_read +pub extern "C" fn BigSize_write(obj: &crate::lightning::util::ser::BigSize) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn BigSize_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBigSize) }) +} +#[no_mangle] +/// Read a BigSize from a byte array, created by BigSize_write +pub extern "C" fn BigSize_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BigSizeDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::BigSize { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::util::ser::Hostname as nativeHostnameImport; pub(crate) type nativeHostname = nativeHostnameImport; @@ -191,3 +245,135 @@ pub extern "C" fn Hostname_len(this_arg: &crate::lightning::util::ser::Hostname) ret } +#[no_mangle] +/// Serialize the Hostname object into a byte array which can be read by Hostname_read +pub extern "C" fn Hostname_write(obj: &crate::lightning::util::ser::Hostname) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Hostname_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHostname) }) +} +#[no_mangle] +/// Read a Hostname from a byte array, created by Hostname_write +pub extern "C" fn Hostname_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HostnameDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::util::ser::TransactionU16LenLimited as nativeTransactionU16LenLimitedImport; +pub(crate) type nativeTransactionU16LenLimited = nativeTransactionU16LenLimitedImport; + +/// A wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`] +/// if the `Transaction`'s consensus-serialized length is <= u16::MAX. +/// +/// Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`. +#[must_use] +#[repr(C)] +pub struct TransactionU16LenLimited { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTransactionU16LenLimited, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TransactionU16LenLimited { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTransactionU16LenLimited>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TransactionU16LenLimited, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_free(this_obj: TransactionU16LenLimited) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TransactionU16LenLimited_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTransactionU16LenLimited) }; +} +#[allow(unused)] +impl TransactionU16LenLimited { + pub(crate) fn get_native_ref(&self) -> &'static nativeTransactionU16LenLimited { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTransactionU16LenLimited { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTransactionU16LenLimited { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for TransactionU16LenLimited { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTransactionU16LenLimited>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TransactionU16LenLimited_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTransactionU16LenLimited)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TransactionU16LenLimited +pub extern "C" fn TransactionU16LenLimited_clone(orig: &TransactionU16LenLimited) -> TransactionU16LenLimited { + orig.clone() +} +/// Checks if two TransactionU16LenLimiteds 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. +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_eq(a: &TransactionU16LenLimited, b: &TransactionU16LenLimited) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus- +/// serialized length is <= u16::MAX. +#[must_use] +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_new(mut transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionU16LenLimitedNoneZ { + let mut ret = lightning::util::ser::TransactionU16LenLimited::new(transaction.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::TransactionU16LenLimited { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`. +#[must_use] +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_into_transaction(mut this_arg: crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::Transaction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_transaction(); + crate::c_types::Transaction::from_bitcoin(&ret) +} + +#[no_mangle] +/// Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read +pub extern "C" fn TransactionU16LenLimited_write(obj: &crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TransactionU16LenLimited_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTransactionU16LenLimited) }) +} +#[no_mangle] +/// Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write +pub extern "C" fn TransactionU16LenLimited_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TransactionU16LenLimitedDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::TransactionU16LenLimited { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning_background_processor.rs b/lightning-c-bindings/src/lightning_background_processor.rs index 4b8360b..d226dfa 100644 --- a/lightning-c-bindings/src/lightning_background_processor.rs +++ b/lightning-c-bindings/src/lightning_background_processor.rs @@ -46,6 +46,8 @@ pub(crate) type nativeBackgroundProcessor = nativeBackgroundProcessorImport; /// /// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor /// [`Event`]: lightning::events::Event +/// [`PeerManager::timer_tick_occurred`]: lightning::ln::peer_handler::PeerManager::timer_tick_occurred +/// [`PeerManager::process_events`]: lightning::ln::peer_handler::PeerManager::process_events ///BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. #[must_use] #[repr(C)] diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 6fb6248..4e8da72 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -11,11 +11,11 @@ //! invoices and functions to create, encode and decode these. If you just want to use the standard //! en-/decoding functionality this should get you started: //! -//! * For parsing use `str::parse::(&self)` (see [`Invoice::from_str`]) +//! * For parsing use `str::parse::(&self)` (see [`Bolt11Invoice::from_str`]) //! * For constructing invoices use the [`InvoiceBuilder`] //! * For serializing invoices use the [`Display`]/[`ToString`] traits //! -//! [`Invoice::from_str`]: crate::Invoice#impl-FromStr +//! [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr use alloc::str::FromStr; use core::ffi::c_void; @@ -62,7 +62,7 @@ use alloc::{vec::Vec, boxed::Box}; } #[no_mangle] /// Read a SiPrefix object from a string -pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SiPrefixParseErrorZ { +pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SiPrefixBolt11ParseErrorZ { match lightning_invoice::SiPrefix::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( @@ -71,18 +71,18 @@ pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::d }, Err(e) => { crate::c_types::CResultTempl::err( - crate::lightning_invoice::ParseError::native_into(e) + crate::lightning_invoice::Bolt11ParseError::native_into(e) ) }, }.into() } #[no_mangle] -/// Read a Invoice object from a string -pub extern "C" fn Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_InvoiceParseOrSemanticErrorZ { - match lightning_invoice::Invoice::from_str(s.into_str()) { +/// Read a Bolt11Invoice object from a string +pub extern "C" fn Bolt11Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_Bolt11InvoiceParseOrSemanticErrorZ { + match lightning_invoice::Bolt11Invoice::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( - crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } + crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } ) }, Err(e) => { @@ -93,24 +93,24 @@ pub extern "C" fn Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::de }.into() } #[no_mangle] -/// Read a SignedRawInvoice object from a string -pub extern "C" fn SignedRawInvoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SignedRawInvoiceParseErrorZ { - match lightning_invoice::SignedRawInvoice::from_str(s.into_str()) { +/// Read a SignedRawBolt11Invoice object from a string +pub extern "C" fn SignedRawBolt11Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + match lightning_invoice::SignedRawBolt11Invoice::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( - crate::lightning_invoice::SignedRawInvoice { inner: ObjOps::heap_alloc(r), is_owned: true } + crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } ) }, Err(e) => { crate::c_types::CResultTempl::err( - crate::lightning_invoice::ParseError::native_into(e) + crate::lightning_invoice::Bolt11ParseError::native_into(e) ) }, }.into() } #[no_mangle] -/// Get the string representation of a ParseError object -pub extern "C" fn ParseError_to_str(o: &crate::lightning_invoice::ParseError) -> Str { +/// Get the string representation of a Bolt11ParseError object +pub extern "C" fn Bolt11ParseError_to_str(o: &crate::lightning_invoice::Bolt11ParseError) -> Str { alloc::format!("{}", &o.to_native()).into() } #[no_mangle] @@ -130,13 +130,13 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; #[no_mangle] -/// Get the string representation of a Invoice object -pub extern "C" fn Invoice_to_str(o: &crate::lightning_invoice::Invoice) -> Str { +/// Get the string representation of a Bolt11Invoice object +pub extern "C" fn Bolt11Invoice_to_str(o: &crate::lightning_invoice::Bolt11Invoice) -> Str { alloc::format!("{}", o.get_native_ref()).into() } #[no_mangle] -/// Get the string representation of a SignedRawInvoice object -pub extern "C" fn SignedRawInvoice_to_str(o: &crate::lightning_invoice::SignedRawInvoice) -> Str { +/// Get the string representation of a SignedRawBolt11Invoice object +pub extern "C" fn SignedRawBolt11Invoice_to_str(o: &crate::lightning_invoice::SignedRawBolt11Invoice) -> Str { alloc::format!("{}", o.get_native_ref()).into() } #[no_mangle] @@ -188,7 +188,7 @@ use alloc::{vec::Vec, boxed::Box}; #[derive(Clone)] #[must_use] #[repr(C)] -pub enum ParseError { +pub enum Bolt11ParseError { Bech32Error( crate::c_types::Bech32Error), ParseAmountError( @@ -215,282 +215,282 @@ pub enum ParseError { /// according to BOLT11 Skip, } -use lightning_invoice::ParseError as ParseErrorImport; -pub(crate) type nativeParseError = ParseErrorImport; +use lightning_invoice::Bolt11ParseError as Bolt11ParseErrorImport; +pub(crate) type nativeBolt11ParseError = Bolt11ParseErrorImport; -impl ParseError { +impl Bolt11ParseError { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeParseError { + pub(crate) fn to_native(&self) -> nativeBolt11ParseError { match self { - ParseError::Bech32Error (ref a, ) => { + Bolt11ParseError::Bech32Error (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::Bech32Error ( + nativeBolt11ParseError::Bech32Error ( a_nonref.into_rust(), ) }, - ParseError::ParseAmountError (ref a, ) => { + Bolt11ParseError::ParseAmountError (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::ParseAmountError ( + nativeBolt11ParseError::ParseAmountError ( u8::from_str_radix(" a", 10).unwrap_err() /*a_nonref*/, ) }, - ParseError::MalformedSignature (ref a, ) => { + Bolt11ParseError::MalformedSignature (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::MalformedSignature ( + nativeBolt11ParseError::MalformedSignature ( a_nonref.into_rust(), ) }, - ParseError::BadPrefix => nativeParseError::BadPrefix, - ParseError::UnknownCurrency => nativeParseError::UnknownCurrency, - ParseError::UnknownSiPrefix => nativeParseError::UnknownSiPrefix, - ParseError::MalformedHRP => nativeParseError::MalformedHRP, - ParseError::TooShortDataPart => nativeParseError::TooShortDataPart, - ParseError::UnexpectedEndOfTaggedFields => nativeParseError::UnexpectedEndOfTaggedFields, - ParseError::DescriptionDecodeError (ref a, ) => { + Bolt11ParseError::BadPrefix => nativeBolt11ParseError::BadPrefix, + Bolt11ParseError::UnknownCurrency => nativeBolt11ParseError::UnknownCurrency, + Bolt11ParseError::UnknownSiPrefix => nativeBolt11ParseError::UnknownSiPrefix, + Bolt11ParseError::MalformedHRP => nativeBolt11ParseError::MalformedHRP, + Bolt11ParseError::TooShortDataPart => nativeBolt11ParseError::TooShortDataPart, + Bolt11ParseError::UnexpectedEndOfTaggedFields => nativeBolt11ParseError::UnexpectedEndOfTaggedFields, + Bolt11ParseError::DescriptionDecodeError (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::DescriptionDecodeError ( + nativeBolt11ParseError::DescriptionDecodeError ( core::str::from_utf8(&[0xff]).unwrap_err() /*a_nonref*/, ) }, - ParseError::PaddingError => nativeParseError::PaddingError, - ParseError::IntegerOverflowError => nativeParseError::IntegerOverflowError, - ParseError::InvalidSegWitProgramLength => nativeParseError::InvalidSegWitProgramLength, - ParseError::InvalidPubKeyHashLength => nativeParseError::InvalidPubKeyHashLength, - ParseError::InvalidScriptHashLength => nativeParseError::InvalidScriptHashLength, - ParseError::InvalidRecoveryId => nativeParseError::InvalidRecoveryId, - ParseError::InvalidSliceLength (ref a, ) => { + Bolt11ParseError::PaddingError => nativeBolt11ParseError::PaddingError, + Bolt11ParseError::IntegerOverflowError => nativeBolt11ParseError::IntegerOverflowError, + Bolt11ParseError::InvalidSegWitProgramLength => nativeBolt11ParseError::InvalidSegWitProgramLength, + Bolt11ParseError::InvalidPubKeyHashLength => nativeBolt11ParseError::InvalidPubKeyHashLength, + Bolt11ParseError::InvalidScriptHashLength => nativeBolt11ParseError::InvalidScriptHashLength, + Bolt11ParseError::InvalidRecoveryId => nativeBolt11ParseError::InvalidRecoveryId, + Bolt11ParseError::InvalidSliceLength (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::InvalidSliceLength ( + nativeBolt11ParseError::InvalidSliceLength ( a_nonref.into_string(), ) }, - ParseError::Skip => nativeParseError::Skip, + Bolt11ParseError::Skip => nativeBolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeParseError { + pub(crate) fn into_native(self) -> nativeBolt11ParseError { match self { - ParseError::Bech32Error (mut a, ) => { - nativeParseError::Bech32Error ( + Bolt11ParseError::Bech32Error (mut a, ) => { + nativeBolt11ParseError::Bech32Error ( a.into_rust(), ) }, - ParseError::ParseAmountError (mut a, ) => { - nativeParseError::ParseAmountError ( + Bolt11ParseError::ParseAmountError (mut a, ) => { + nativeBolt11ParseError::ParseAmountError ( u8::from_str_radix(" a", 10).unwrap_err() /*a*/, ) }, - ParseError::MalformedSignature (mut a, ) => { - nativeParseError::MalformedSignature ( + Bolt11ParseError::MalformedSignature (mut a, ) => { + nativeBolt11ParseError::MalformedSignature ( a.into_rust(), ) }, - ParseError::BadPrefix => nativeParseError::BadPrefix, - ParseError::UnknownCurrency => nativeParseError::UnknownCurrency, - ParseError::UnknownSiPrefix => nativeParseError::UnknownSiPrefix, - ParseError::MalformedHRP => nativeParseError::MalformedHRP, - ParseError::TooShortDataPart => nativeParseError::TooShortDataPart, - ParseError::UnexpectedEndOfTaggedFields => nativeParseError::UnexpectedEndOfTaggedFields, - ParseError::DescriptionDecodeError (mut a, ) => { - nativeParseError::DescriptionDecodeError ( + Bolt11ParseError::BadPrefix => nativeBolt11ParseError::BadPrefix, + Bolt11ParseError::UnknownCurrency => nativeBolt11ParseError::UnknownCurrency, + Bolt11ParseError::UnknownSiPrefix => nativeBolt11ParseError::UnknownSiPrefix, + Bolt11ParseError::MalformedHRP => nativeBolt11ParseError::MalformedHRP, + Bolt11ParseError::TooShortDataPart => nativeBolt11ParseError::TooShortDataPart, + Bolt11ParseError::UnexpectedEndOfTaggedFields => nativeBolt11ParseError::UnexpectedEndOfTaggedFields, + Bolt11ParseError::DescriptionDecodeError (mut a, ) => { + nativeBolt11ParseError::DescriptionDecodeError ( core::str::from_utf8(&[0xff]).unwrap_err() /*a*/, ) }, - ParseError::PaddingError => nativeParseError::PaddingError, - ParseError::IntegerOverflowError => nativeParseError::IntegerOverflowError, - ParseError::InvalidSegWitProgramLength => nativeParseError::InvalidSegWitProgramLength, - ParseError::InvalidPubKeyHashLength => nativeParseError::InvalidPubKeyHashLength, - ParseError::InvalidScriptHashLength => nativeParseError::InvalidScriptHashLength, - ParseError::InvalidRecoveryId => nativeParseError::InvalidRecoveryId, - ParseError::InvalidSliceLength (mut a, ) => { - nativeParseError::InvalidSliceLength ( + Bolt11ParseError::PaddingError => nativeBolt11ParseError::PaddingError, + Bolt11ParseError::IntegerOverflowError => nativeBolt11ParseError::IntegerOverflowError, + Bolt11ParseError::InvalidSegWitProgramLength => nativeBolt11ParseError::InvalidSegWitProgramLength, + Bolt11ParseError::InvalidPubKeyHashLength => nativeBolt11ParseError::InvalidPubKeyHashLength, + Bolt11ParseError::InvalidScriptHashLength => nativeBolt11ParseError::InvalidScriptHashLength, + Bolt11ParseError::InvalidRecoveryId => nativeBolt11ParseError::InvalidRecoveryId, + Bolt11ParseError::InvalidSliceLength (mut a, ) => { + nativeBolt11ParseError::InvalidSliceLength ( a.into_string(), ) }, - ParseError::Skip => nativeParseError::Skip, + Bolt11ParseError::Skip => nativeBolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeParseError) -> Self { + pub(crate) fn from_native(native: &nativeBolt11ParseError) -> Self { match native { - nativeParseError::Bech32Error (ref a, ) => { + nativeBolt11ParseError::Bech32Error (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::Bech32Error ( + Bolt11ParseError::Bech32Error ( crate::c_types::Bech32Error::from_rust(a_nonref), ) }, - nativeParseError::ParseAmountError (ref a, ) => { + nativeBolt11ParseError::ParseAmountError (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::ParseAmountError ( + Bolt11ParseError::ParseAmountError ( crate::c_types::Error { _dummy: 0 } /*a_nonref*/, ) }, - nativeParseError::MalformedSignature (ref a, ) => { + nativeBolt11ParseError::MalformedSignature (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::MalformedSignature ( + Bolt11ParseError::MalformedSignature ( crate::c_types::Secp256k1Error::from_rust(a_nonref), ) }, - nativeParseError::BadPrefix => ParseError::BadPrefix, - nativeParseError::UnknownCurrency => ParseError::UnknownCurrency, - nativeParseError::UnknownSiPrefix => ParseError::UnknownSiPrefix, - nativeParseError::MalformedHRP => ParseError::MalformedHRP, - nativeParseError::TooShortDataPart => ParseError::TooShortDataPart, - nativeParseError::UnexpectedEndOfTaggedFields => ParseError::UnexpectedEndOfTaggedFields, - nativeParseError::DescriptionDecodeError (ref a, ) => { + nativeBolt11ParseError::BadPrefix => Bolt11ParseError::BadPrefix, + nativeBolt11ParseError::UnknownCurrency => Bolt11ParseError::UnknownCurrency, + nativeBolt11ParseError::UnknownSiPrefix => Bolt11ParseError::UnknownSiPrefix, + nativeBolt11ParseError::MalformedHRP => Bolt11ParseError::MalformedHRP, + nativeBolt11ParseError::TooShortDataPart => Bolt11ParseError::TooShortDataPart, + nativeBolt11ParseError::UnexpectedEndOfTaggedFields => Bolt11ParseError::UnexpectedEndOfTaggedFields, + nativeBolt11ParseError::DescriptionDecodeError (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::DescriptionDecodeError ( + Bolt11ParseError::DescriptionDecodeError ( crate::c_types::Error { _dummy: 0 } /*a_nonref*/, ) }, - nativeParseError::PaddingError => ParseError::PaddingError, - nativeParseError::IntegerOverflowError => ParseError::IntegerOverflowError, - nativeParseError::InvalidSegWitProgramLength => ParseError::InvalidSegWitProgramLength, - nativeParseError::InvalidPubKeyHashLength => ParseError::InvalidPubKeyHashLength, - nativeParseError::InvalidScriptHashLength => ParseError::InvalidScriptHashLength, - nativeParseError::InvalidRecoveryId => ParseError::InvalidRecoveryId, - nativeParseError::InvalidSliceLength (ref a, ) => { + nativeBolt11ParseError::PaddingError => Bolt11ParseError::PaddingError, + nativeBolt11ParseError::IntegerOverflowError => Bolt11ParseError::IntegerOverflowError, + nativeBolt11ParseError::InvalidSegWitProgramLength => Bolt11ParseError::InvalidSegWitProgramLength, + nativeBolt11ParseError::InvalidPubKeyHashLength => Bolt11ParseError::InvalidPubKeyHashLength, + nativeBolt11ParseError::InvalidScriptHashLength => Bolt11ParseError::InvalidScriptHashLength, + nativeBolt11ParseError::InvalidRecoveryId => Bolt11ParseError::InvalidRecoveryId, + nativeBolt11ParseError::InvalidSliceLength (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::InvalidSliceLength ( + Bolt11ParseError::InvalidSliceLength ( a_nonref.into(), ) }, - nativeParseError::Skip => ParseError::Skip, + nativeBolt11ParseError::Skip => Bolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeParseError) -> Self { + pub(crate) fn native_into(native: nativeBolt11ParseError) -> Self { match native { - nativeParseError::Bech32Error (mut a, ) => { - ParseError::Bech32Error ( + nativeBolt11ParseError::Bech32Error (mut a, ) => { + Bolt11ParseError::Bech32Error ( crate::c_types::Bech32Error::from_rust(a), ) }, - nativeParseError::ParseAmountError (mut a, ) => { - ParseError::ParseAmountError ( + nativeBolt11ParseError::ParseAmountError (mut a, ) => { + Bolt11ParseError::ParseAmountError ( crate::c_types::Error { _dummy: 0 } /*a*/, ) }, - nativeParseError::MalformedSignature (mut a, ) => { - ParseError::MalformedSignature ( + nativeBolt11ParseError::MalformedSignature (mut a, ) => { + Bolt11ParseError::MalformedSignature ( crate::c_types::Secp256k1Error::from_rust(a), ) }, - nativeParseError::BadPrefix => ParseError::BadPrefix, - nativeParseError::UnknownCurrency => ParseError::UnknownCurrency, - nativeParseError::UnknownSiPrefix => ParseError::UnknownSiPrefix, - nativeParseError::MalformedHRP => ParseError::MalformedHRP, - nativeParseError::TooShortDataPart => ParseError::TooShortDataPart, - nativeParseError::UnexpectedEndOfTaggedFields => ParseError::UnexpectedEndOfTaggedFields, - nativeParseError::DescriptionDecodeError (mut a, ) => { - ParseError::DescriptionDecodeError ( + nativeBolt11ParseError::BadPrefix => Bolt11ParseError::BadPrefix, + nativeBolt11ParseError::UnknownCurrency => Bolt11ParseError::UnknownCurrency, + nativeBolt11ParseError::UnknownSiPrefix => Bolt11ParseError::UnknownSiPrefix, + nativeBolt11ParseError::MalformedHRP => Bolt11ParseError::MalformedHRP, + nativeBolt11ParseError::TooShortDataPart => Bolt11ParseError::TooShortDataPart, + nativeBolt11ParseError::UnexpectedEndOfTaggedFields => Bolt11ParseError::UnexpectedEndOfTaggedFields, + nativeBolt11ParseError::DescriptionDecodeError (mut a, ) => { + Bolt11ParseError::DescriptionDecodeError ( crate::c_types::Error { _dummy: 0 } /*a*/, ) }, - nativeParseError::PaddingError => ParseError::PaddingError, - nativeParseError::IntegerOverflowError => ParseError::IntegerOverflowError, - nativeParseError::InvalidSegWitProgramLength => ParseError::InvalidSegWitProgramLength, - nativeParseError::InvalidPubKeyHashLength => ParseError::InvalidPubKeyHashLength, - nativeParseError::InvalidScriptHashLength => ParseError::InvalidScriptHashLength, - nativeParseError::InvalidRecoveryId => ParseError::InvalidRecoveryId, - nativeParseError::InvalidSliceLength (mut a, ) => { - ParseError::InvalidSliceLength ( + nativeBolt11ParseError::PaddingError => Bolt11ParseError::PaddingError, + nativeBolt11ParseError::IntegerOverflowError => Bolt11ParseError::IntegerOverflowError, + nativeBolt11ParseError::InvalidSegWitProgramLength => Bolt11ParseError::InvalidSegWitProgramLength, + nativeBolt11ParseError::InvalidPubKeyHashLength => Bolt11ParseError::InvalidPubKeyHashLength, + nativeBolt11ParseError::InvalidScriptHashLength => Bolt11ParseError::InvalidScriptHashLength, + nativeBolt11ParseError::InvalidRecoveryId => Bolt11ParseError::InvalidRecoveryId, + nativeBolt11ParseError::InvalidSliceLength (mut a, ) => { + Bolt11ParseError::InvalidSliceLength ( a.into(), ) }, - nativeParseError::Skip => ParseError::Skip, + nativeBolt11ParseError::Skip => Bolt11ParseError::Skip, } } } -/// Frees any resources used by the ParseError +/// Frees any resources used by the Bolt11ParseError #[no_mangle] -pub extern "C" fn ParseError_free(this_ptr: ParseError) { } -/// Creates a copy of the ParseError +pub extern "C" fn Bolt11ParseError_free(this_ptr: Bolt11ParseError) { } +/// Creates a copy of the Bolt11ParseError #[no_mangle] -pub extern "C" fn ParseError_clone(orig: &ParseError) -> ParseError { +pub extern "C" fn Bolt11ParseError_clone(orig: &Bolt11ParseError) -> Bolt11ParseError { orig.clone() } #[no_mangle] -/// Utility method to constructs a new Bech32Error-variant ParseError -pub extern "C" fn ParseError_bech32_error(a: crate::c_types::Bech32Error) -> ParseError { - ParseError::Bech32Error(a, ) +/// Utility method to constructs a new Bech32Error-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_bech32_error(a: crate::c_types::Bech32Error) -> Bolt11ParseError { + Bolt11ParseError::Bech32Error(a, ) } #[no_mangle] -/// Utility method to constructs a new ParseAmountError-variant ParseError -pub extern "C" fn ParseError_parse_amount_error(a: crate::c_types::Error) -> ParseError { - ParseError::ParseAmountError(a, ) +/// Utility method to constructs a new ParseAmountError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_parse_amount_error(a: crate::c_types::Error) -> Bolt11ParseError { + Bolt11ParseError::ParseAmountError(a, ) } #[no_mangle] -/// Utility method to constructs a new MalformedSignature-variant ParseError -pub extern "C" fn ParseError_malformed_signature(a: crate::c_types::Secp256k1Error) -> ParseError { - ParseError::MalformedSignature(a, ) +/// Utility method to constructs a new MalformedSignature-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_malformed_signature(a: crate::c_types::Secp256k1Error) -> Bolt11ParseError { + Bolt11ParseError::MalformedSignature(a, ) } #[no_mangle] -/// Utility method to constructs a new BadPrefix-variant ParseError -pub extern "C" fn ParseError_bad_prefix() -> ParseError { - ParseError::BadPrefix} +/// Utility method to constructs a new BadPrefix-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_bad_prefix() -> Bolt11ParseError { + Bolt11ParseError::BadPrefix} #[no_mangle] -/// Utility method to constructs a new UnknownCurrency-variant ParseError -pub extern "C" fn ParseError_unknown_currency() -> ParseError { - ParseError::UnknownCurrency} +/// Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unknown_currency() -> Bolt11ParseError { + Bolt11ParseError::UnknownCurrency} #[no_mangle] -/// Utility method to constructs a new UnknownSiPrefix-variant ParseError -pub extern "C" fn ParseError_unknown_si_prefix() -> ParseError { - ParseError::UnknownSiPrefix} +/// Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unknown_si_prefix() -> Bolt11ParseError { + Bolt11ParseError::UnknownSiPrefix} #[no_mangle] -/// Utility method to constructs a new MalformedHRP-variant ParseError -pub extern "C" fn ParseError_malformed_hrp() -> ParseError { - ParseError::MalformedHRP} +/// Utility method to constructs a new MalformedHRP-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_malformed_hrp() -> Bolt11ParseError { + Bolt11ParseError::MalformedHRP} #[no_mangle] -/// Utility method to constructs a new TooShortDataPart-variant ParseError -pub extern "C" fn ParseError_too_short_data_part() -> ParseError { - ParseError::TooShortDataPart} +/// Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_too_short_data_part() -> Bolt11ParseError { + Bolt11ParseError::TooShortDataPart} #[no_mangle] -/// Utility method to constructs a new UnexpectedEndOfTaggedFields-variant ParseError -pub extern "C" fn ParseError_unexpected_end_of_tagged_fields() -> ParseError { - ParseError::UnexpectedEndOfTaggedFields} +/// Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unexpected_end_of_tagged_fields() -> Bolt11ParseError { + Bolt11ParseError::UnexpectedEndOfTaggedFields} #[no_mangle] -/// Utility method to constructs a new DescriptionDecodeError-variant ParseError -pub extern "C" fn ParseError_description_decode_error(a: crate::c_types::Error) -> ParseError { - ParseError::DescriptionDecodeError(a, ) +/// Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_description_decode_error(a: crate::c_types::Error) -> Bolt11ParseError { + Bolt11ParseError::DescriptionDecodeError(a, ) } #[no_mangle] -/// Utility method to constructs a new PaddingError-variant ParseError -pub extern "C" fn ParseError_padding_error() -> ParseError { - ParseError::PaddingError} +/// Utility method to constructs a new PaddingError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_padding_error() -> Bolt11ParseError { + Bolt11ParseError::PaddingError} #[no_mangle] -/// Utility method to constructs a new IntegerOverflowError-variant ParseError -pub extern "C" fn ParseError_integer_overflow_error() -> ParseError { - ParseError::IntegerOverflowError} +/// Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_integer_overflow_error() -> Bolt11ParseError { + Bolt11ParseError::IntegerOverflowError} #[no_mangle] -/// Utility method to constructs a new InvalidSegWitProgramLength-variant ParseError -pub extern "C" fn ParseError_invalid_seg_wit_program_length() -> ParseError { - ParseError::InvalidSegWitProgramLength} +/// Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_seg_wit_program_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidSegWitProgramLength} #[no_mangle] -/// Utility method to constructs a new InvalidPubKeyHashLength-variant ParseError -pub extern "C" fn ParseError_invalid_pub_key_hash_length() -> ParseError { - ParseError::InvalidPubKeyHashLength} +/// Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_pub_key_hash_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidPubKeyHashLength} #[no_mangle] -/// Utility method to constructs a new InvalidScriptHashLength-variant ParseError -pub extern "C" fn ParseError_invalid_script_hash_length() -> ParseError { - ParseError::InvalidScriptHashLength} +/// Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_script_hash_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidScriptHashLength} #[no_mangle] -/// Utility method to constructs a new InvalidRecoveryId-variant ParseError -pub extern "C" fn ParseError_invalid_recovery_id() -> ParseError { - ParseError::InvalidRecoveryId} +/// Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_recovery_id() -> Bolt11ParseError { + Bolt11ParseError::InvalidRecoveryId} #[no_mangle] -/// Utility method to constructs a new InvalidSliceLength-variant ParseError -pub extern "C" fn ParseError_invalid_slice_length(a: crate::c_types::Str) -> ParseError { - ParseError::InvalidSliceLength(a, ) +/// Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_slice_length(a: crate::c_types::Str) -> Bolt11ParseError { + Bolt11ParseError::InvalidSliceLength(a, ) } #[no_mangle] -/// Utility method to constructs a new Skip-variant ParseError -pub extern "C" fn ParseError_skip() -> ParseError { - ParseError::Skip} -/// Checks if two ParseErrors contain equal inner contents. +/// Utility method to constructs a new Skip-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_skip() -> Bolt11ParseError { + Bolt11ParseError::Skip} +/// Checks if two Bolt11ParseErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn ParseError_eq(a: &ParseError, b: &ParseError) -> bool { +pub extern "C" fn Bolt11ParseError_eq(a: &Bolt11ParseError, b: &Bolt11ParseError) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } /// Indicates that something went wrong while parsing or validating the invoice. Parsing errors @@ -502,10 +502,10 @@ pub extern "C" fn ParseError_eq(a: &ParseError, b: &ParseError) -> bool { pub enum ParseOrSemanticError { /// The invoice couldn't be decoded ParseError( - crate::lightning_invoice::ParseError), + crate::lightning_invoice::Bolt11ParseError), /// The invoice could be decoded but violates the BOLT11 standard SemanticError( - crate::lightning_invoice::SemanticError), + crate::lightning_invoice::Bolt11SemanticError), } use lightning_invoice::ParseOrSemanticError as ParseOrSemanticErrorImport; pub(crate) type nativeParseOrSemanticError = ParseOrSemanticErrorImport; @@ -549,13 +549,13 @@ impl ParseOrSemanticError { nativeParseOrSemanticError::ParseError (ref a, ) => { let mut a_nonref = Clone::clone(a); ParseOrSemanticError::ParseError ( - crate::lightning_invoice::ParseError::native_into(a_nonref), + crate::lightning_invoice::Bolt11ParseError::native_into(a_nonref), ) }, nativeParseOrSemanticError::SemanticError (ref a, ) => { let mut a_nonref = Clone::clone(a); ParseOrSemanticError::SemanticError ( - crate::lightning_invoice::SemanticError::native_into(a_nonref), + crate::lightning_invoice::Bolt11SemanticError::native_into(a_nonref), ) }, } @@ -565,12 +565,12 @@ impl ParseOrSemanticError { match native { nativeParseOrSemanticError::ParseError (mut a, ) => { ParseOrSemanticError::ParseError ( - crate::lightning_invoice::ParseError::native_into(a), + crate::lightning_invoice::Bolt11ParseError::native_into(a), ) }, nativeParseOrSemanticError::SemanticError (mut a, ) => { ParseOrSemanticError::SemanticError ( - crate::lightning_invoice::SemanticError::native_into(a), + crate::lightning_invoice::Bolt11SemanticError::native_into(a), ) }, } @@ -586,12 +586,12 @@ pub extern "C" fn ParseOrSemanticError_clone(orig: &ParseOrSemanticError) -> Par } #[no_mangle] /// Utility method to constructs a new ParseError-variant ParseOrSemanticError -pub extern "C" fn ParseOrSemanticError_parse_error(a: crate::lightning_invoice::ParseError) -> ParseOrSemanticError { +pub extern "C" fn ParseOrSemanticError_parse_error(a: crate::lightning_invoice::Bolt11ParseError) -> ParseOrSemanticError { ParseOrSemanticError::ParseError(a, ) } #[no_mangle] /// Utility method to constructs a new SemanticError-variant ParseOrSemanticError -pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::SemanticError) -> ParseOrSemanticError { +pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::Bolt11SemanticError) -> ParseOrSemanticError { ParseOrSemanticError::SemanticError(a, ) } /// Checks if two ParseOrSemanticErrors contain equal inner contents. @@ -623,25 +623,25 @@ pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; -use lightning_invoice::Invoice as nativeInvoiceImport; -pub(crate) type nativeInvoice = nativeInvoiceImport; +use lightning_invoice::Bolt11Invoice as nativeBolt11InvoiceImport; +pub(crate) type nativeBolt11Invoice = nativeBolt11InvoiceImport; /// Represents a syntactically and semantically correct lightning BOLT11 invoice. /// -/// There are three ways to construct an `Invoice`: +/// There are three ways to construct a `Bolt11Invoice`: /// 1. using [`InvoiceBuilder`] -/// 2. using [`Invoice::from_signed`] -/// 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) +/// 2. using [`Bolt11Invoice::from_signed`] +/// 3. using `str::parse::(&str)` (see [`Bolt11Invoice::from_str`]) /// -/// [`Invoice::from_str`]: crate::Invoice#impl-FromStr +/// [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr #[must_use] #[repr(C)] -pub struct Invoice { +pub struct Bolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoice, + pub inner: *mut nativeBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -649,50 +649,50 @@ pub struct Invoice { pub is_owned: bool, } -impl Drop for Invoice { +impl Drop for Bolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn Invoice_free(this_obj: Invoice) { } +pub extern "C" fn Bolt11Invoice_free(this_obj: Bolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Invoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoice) }; +pub(crate) extern "C" fn Bolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11Invoice) }; } #[allow(unused)] -impl Invoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoice { +impl Bolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -/// Checks if two Invoices contain equal inner contents. +/// Checks if two Bolt11Invoices 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. #[no_mangle] -pub extern "C" fn Invoice_eq(a: &Invoice, b: &Invoice) -> bool { +pub extern "C" fn Bolt11Invoice_eq(a: &Bolt11Invoice, b: &Bolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for Invoice { +impl Clone for Bolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -700,17 +700,17 @@ impl Clone for Invoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the Invoice -pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice { +/// Creates a copy of the Bolt11Invoice +pub extern "C" fn Bolt11Invoice_clone(orig: &Bolt11Invoice) -> Bolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the Invoice. +/// Generates a non-cryptographic 64-bit hash of the Bolt11Invoice. #[no_mangle] -pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_hash(o: &Bolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -719,22 +719,22 @@ pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { core::hash::Hasher::finish(&hasher) } -use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport; -pub(crate) type nativeSignedRawInvoice = nativeSignedRawInvoiceImport; +use lightning_invoice::SignedRawBolt11Invoice as nativeSignedRawBolt11InvoiceImport; +pub(crate) type nativeSignedRawBolt11Invoice = nativeSignedRawBolt11InvoiceImport; -/// Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be +/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be /// invalid. /// /// # Invariants -/// The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. +/// The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice`]. #[must_use] #[repr(C)] -pub struct SignedRawInvoice { +pub struct SignedRawBolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeSignedRawInvoice, + pub inner: *mut nativeSignedRawBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -742,50 +742,50 @@ pub struct SignedRawInvoice { pub is_owned: bool, } -impl Drop for SignedRawInvoice { +impl Drop for SignedRawBolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeSignedRawInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn SignedRawInvoice_free(this_obj: SignedRawInvoice) { } +pub extern "C" fn SignedRawBolt11Invoice_free(this_obj: SignedRawBolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn SignedRawInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawInvoice) }; +pub(crate) extern "C" fn SignedRawBolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawBolt11Invoice) }; } #[allow(unused)] -impl SignedRawInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeSignedRawInvoice { +impl SignedRawBolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeSignedRawBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSignedRawInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSignedRawBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -/// Checks if two SignedRawInvoices contain equal inner contents. +/// Checks if two SignedRawBolt11Invoices 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. #[no_mangle] -pub extern "C" fn SignedRawInvoice_eq(a: &SignedRawInvoice, b: &SignedRawInvoice) -> bool { +pub extern "C" fn SignedRawBolt11Invoice_eq(a: &SignedRawBolt11Invoice, b: &SignedRawBolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for SignedRawInvoice { +impl Clone for SignedRawBolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -793,17 +793,17 @@ impl Clone for SignedRawInvoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn SignedRawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn SignedRawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the SignedRawInvoice -pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice { +/// Creates a copy of the SignedRawBolt11Invoice +pub extern "C" fn SignedRawBolt11Invoice_clone(orig: &SignedRawBolt11Invoice) -> SignedRawBolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the SignedRawInvoice. +/// Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice. #[no_mangle] -pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { +pub extern "C" fn SignedRawBolt11Invoice_hash(o: &SignedRawBolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -812,22 +812,22 @@ pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { core::hash::Hasher::finish(&hasher) } -use lightning_invoice::RawInvoice as nativeRawInvoiceImport; -pub(crate) type nativeRawInvoice = nativeRawInvoiceImport; +use lightning_invoice::RawBolt11Invoice as nativeRawBolt11InvoiceImport; +pub(crate) type nativeRawBolt11Invoice = nativeRawBolt11InvoiceImport; -/// Represents an syntactically correct [`Invoice`] for a payment on the lightning network, +/// Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network, /// but without the signature information. /// Decoding and encoding should not lead to information loss but may lead to different hashes. /// -/// For methods without docs see the corresponding methods in [`Invoice`]. +/// For methods without docs see the corresponding methods in [`Bolt11Invoice`]. #[must_use] #[repr(C)] -pub struct RawInvoice { +pub struct RawBolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeRawInvoice, + pub inner: *mut nativeRawBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -835,31 +835,31 @@ pub struct RawInvoice { pub is_owned: bool, } -impl Drop for RawInvoice { +impl Drop for RawBolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeRawInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeRawBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn RawInvoice_free(this_obj: RawInvoice) { } +pub extern "C" fn RawBolt11Invoice_free(this_obj: RawBolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RawInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawInvoice) }; +pub(crate) extern "C" fn RawBolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawBolt11Invoice) }; } #[allow(unused)] -impl RawInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeRawInvoice { +impl RawBolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeRawBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeRawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeRawBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -868,28 +868,28 @@ impl RawInvoice { } /// data part #[no_mangle] -pub extern "C" fn RawInvoice_get_data(this_ptr: &RawInvoice) -> crate::lightning_invoice::RawDataPart { +pub extern "C" fn RawBolt11Invoice_get_data(this_ptr: &RawBolt11Invoice) -> crate::lightning_invoice::RawDataPart { let mut inner_val = &mut this_ptr.get_native_mut_ref().data; crate::lightning_invoice::RawDataPart { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_invoice::RawDataPart<>) as *mut _) }, is_owned: false } } /// data part #[no_mangle] -pub extern "C" fn RawInvoice_set_data(this_ptr: &mut RawInvoice, mut val: crate::lightning_invoice::RawDataPart) { +pub extern "C" fn RawBolt11Invoice_set_data(this_ptr: &mut RawBolt11Invoice, mut val: crate::lightning_invoice::RawDataPart) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = *unsafe { Box::from_raw(val.take_inner()) }; } -/// Checks if two RawInvoices contain equal inner contents. +/// Checks if two RawBolt11Invoices 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. #[no_mangle] -pub extern "C" fn RawInvoice_eq(a: &RawInvoice, b: &RawInvoice) -> bool { +pub extern "C" fn RawBolt11Invoice_eq(a: &RawBolt11Invoice, b: &RawBolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for RawInvoice { +impl Clone for RawBolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -897,17 +897,17 @@ impl Clone for RawInvoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn RawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the RawInvoice -pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice { +/// Creates a copy of the RawBolt11Invoice +pub extern "C" fn RawBolt11Invoice_clone(orig: &RawBolt11Invoice) -> RawBolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the RawInvoice. +/// Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice. #[no_mangle] -pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { +pub extern "C" fn RawBolt11Invoice_hash(o: &RawBolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -919,7 +919,7 @@ pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { use lightning_invoice::RawDataPart as nativeRawDataPartImport; pub(crate) type nativeRawDataPart = nativeRawDataPartImport; -/// Data of the [`RawInvoice`] that is encoded in the data part +/// Data of the [`RawBolt11Invoice`] that is encoded in the data part #[must_use] #[repr(C)] pub struct RawDataPart { @@ -1959,18 +1959,18 @@ pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport; -pub(crate) type nativeInvoiceSignature = nativeInvoiceSignatureImport; +use lightning_invoice::Bolt11InvoiceSignature as nativeBolt11InvoiceSignatureImport; +pub(crate) type nativeBolt11InvoiceSignature = nativeBolt11InvoiceSignatureImport; /// Recoverable signature #[must_use] #[repr(C)] -pub struct InvoiceSignature { +pub struct Bolt11InvoiceSignature { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoiceSignature, + pub inner: *mut nativeBolt11InvoiceSignature, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1978,41 +1978,41 @@ pub struct InvoiceSignature { pub is_owned: bool, } -impl Drop for InvoiceSignature { +impl Drop for Bolt11InvoiceSignature { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceSignature>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn InvoiceSignature_free(this_obj: InvoiceSignature) { } +pub extern "C" fn Bolt11InvoiceSignature_free(this_obj: Bolt11InvoiceSignature) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceSignature) }; +pub(crate) extern "C" fn Bolt11InvoiceSignature_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceSignature) }; } #[allow(unused)] -impl InvoiceSignature { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceSignature { +impl Bolt11InvoiceSignature { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceSignature { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceSignature { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceSignature { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceSignature { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -impl Clone for InvoiceSignature { +impl Clone for Bolt11InvoiceSignature { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2020,17 +2020,17 @@ impl Clone for InvoiceSignature { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceSignature)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11InvoiceSignature)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the InvoiceSignature -pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature { +/// Creates a copy of the Bolt11InvoiceSignature +pub extern "C" fn Bolt11InvoiceSignature_clone(orig: &Bolt11InvoiceSignature) -> Bolt11InvoiceSignature { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the InvoiceSignature. +/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature. #[no_mangle] -pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 { +pub extern "C" fn Bolt11InvoiceSignature_hash(o: &Bolt11InvoiceSignature) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -2038,11 +2038,11 @@ pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two InvoiceSignatures contain equal inner contents. +/// Checks if two Bolt11InvoiceSignatures 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. #[no_mangle] -pub extern "C" fn InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> bool { +pub extern "C" fn Bolt11InvoiceSignature_eq(a: &Bolt11InvoiceSignature, b: &Bolt11InvoiceSignature) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -2140,30 +2140,30 @@ pub extern "C" fn PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Disassembles the `SignedRawInvoice` into its three parts: +/// Disassembles the `SignedRawBolt11Invoice` into its three parts: /// 1. raw invoice /// 2. hash of the raw invoice /// 3. signature #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ { +pub extern "C" fn SignedRawBolt11Invoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts(); - let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawInvoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into(); + let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawBolt11Invoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::Bolt11InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into(); local_ret } -/// The [`RawInvoice`] which was signed. +/// The [`RawBolt11Invoice`] which was signed. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::RawInvoice { +pub extern "C" fn SignedRawBolt11Invoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::RawBolt11Invoice { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.raw_invoice(); - crate::lightning_invoice::RawInvoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawInvoice<>) as *mut _) }, is_owned: false } + crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false } } -/// The hash of the [`RawInvoice`] that was signed. +/// The hash of the [`RawBolt11Invoice`] that was signed. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] { +pub extern "C" fn SignedRawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); ret } @@ -2171,15 +2171,15 @@ pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_inv /// Signature for the invoice. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature { +pub extern "C" fn SignedRawBolt11Invoice_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::Bolt11InvoiceSignature { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature(); - crate::lightning_invoice::InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::InvoiceSignature<>) as *mut _) }, is_owned: false } + crate::lightning_invoice::Bolt11InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::Bolt11InvoiceSignature<>) as *mut _) }, is_owned: false } } /// Recovers the public key used for signing the invoice from the recoverable signature. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ { +pub extern "C" fn SignedRawBolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key(); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PayeePubKey { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; local_ret @@ -2189,15 +2189,15 @@ pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &crate::light /// valid for the recovered signature (which should always be true?). #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> bool { +pub extern "C" fn SignedRawBolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature(); ret } -/// Calculate the hash of the encoded `RawInvoice` which should be signed. +/// Calculate the hash of the encoded `RawBolt11Invoice` which should be signed. #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); crate::c_types::ThirtyTwoBytes { data: ret } } @@ -2206,7 +2206,7 @@ pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 { +pub extern "C" fn RawBolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false }; local_ret @@ -2216,7 +2216,7 @@ pub extern "C" fn RawInvoice_payment_hash(this_arg: &crate::lightning_invoice::R /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_description(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Description { +pub extern "C" fn RawBolt11Invoice_description(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Description { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Description<>) as *mut _ }, is_owned: false }; local_ret @@ -2226,7 +2226,7 @@ pub extern "C" fn RawInvoice_description(this_arg: &crate::lightning_invoice::Ra /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::PayeePubKey { +pub extern "C" fn RawBolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::PayeePubKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key(); let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::PayeePubKey<>) as *mut _ }, is_owned: false }; local_ret @@ -2236,7 +2236,7 @@ pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_description_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 { +pub extern "C" fn RawBolt11Invoice_description_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description_hash(); let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false }; local_ret @@ -2246,7 +2246,7 @@ pub extern "C" fn RawInvoice_description_hash(this_arg: &crate::lightning_invoic /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_expiry_time(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::ExpiryTime { +pub extern "C" fn RawBolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::ExpiryTime { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time(); let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::ExpiryTime<>) as *mut _ }, is_owned: false }; local_ret @@ -2256,25 +2256,23 @@ pub extern "C" fn RawInvoice_expiry_time(this_arg: &crate::lightning_invoice::Ra /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiryDelta { +pub extern "C" fn RawBolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::MinFinalCltvExpiryDelta { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta(); let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiryDelta { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiryDelta<>) as *mut _ }, is_owned: false }; local_ret } -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_secret(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RawBolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_PaymentSecretZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret(); - let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_PaymentSecretZ::None } else { crate::c_types::derived::COption_PaymentSecretZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*ret.as_ref().unwrap()).clone().0 } }) }; local_ret } #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_metadata(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_CVec_u8ZZ { +pub extern "C" fn RawBolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; local_ret @@ -2284,15 +2282,15 @@ pub extern "C" fn RawInvoice_payment_metadata(this_arg: &crate::lightning_invoic /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_features(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures { +pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_private_routes(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::CVec_PrivateRouteZ { +pub extern "C" fn RawBolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); }; local_ret.into() @@ -2300,7 +2298,7 @@ pub extern "C" fn RawInvoice_private_routes(this_arg: &crate::lightning_invoice: #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn RawBolt11Invoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_u64Z { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; local_ret @@ -2308,7 +2306,7 @@ pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &crate::lightning_invoice #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_currency(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Currency { +pub extern "C" fn RawBolt11Invoice_currency(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Currency { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency(); crate::lightning_invoice::Currency::native_into(ret) } @@ -2376,32 +2374,32 @@ pub extern "C" fn PositiveTimestamp_as_time(this_arg: &crate::lightning_invoice: ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() } -/// The hash of the [`RawInvoice`] that was signed. +/// The hash of the [`RawBolt11Invoice`] that was signed. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_signable_hash(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn Bolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); crate::c_types::ThirtyTwoBytes { data: ret } } -/// Transform the `Invoice` into it's unchecked version +/// Transform the `Bolt11Invoice` into its unchecked version. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Invoice) -> crate::lightning_invoice::SignedRawInvoice { +pub extern "C" fn Bolt11Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::SignedRawBolt11Invoice { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw(); - crate::lightning_invoice::SignedRawInvoice { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Check that the invoice is signed correctly and that key recovery works #[must_use] #[no_mangle] -pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ { +pub extern "C" fn Bolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_NoneBolt11SemanticErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature(); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() }; local_ret } -/// Constructs an `Invoice` from a [`SignedRawInvoice`] by checking all its invariants. +/// Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants. /// ``` /// use lightning_invoice::*; /// @@ -2417,30 +2415,30 @@ pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::I /// 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ /// j5r6drg6k6zcqj0fcwg\"; /// -/// let signed = invoice.parse::().unwrap(); +/// let signed = invoice.parse::().unwrap(); /// -/// assert!(Invoice::from_signed(signed).is_ok()); +/// assert!(Bolt11Invoice::from_signed(signed).is_ok()); /// ``` #[must_use] #[no_mangle] -pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_InvoiceSemanticErrorZ { - let mut ret = lightning_invoice::Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; +pub extern "C" fn Bolt11Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_Bolt11InvoiceBolt11SemanticErrorZ { + let mut ret = lightning_invoice::Bolt11Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() }; local_ret } -/// Returns the `Invoice`'s timestamp (should equal its creation time) +/// Returns the `Bolt11Invoice`'s timestamp (should equal its creation time) #[must_use] #[no_mangle] -pub extern "C" fn Invoice_timestamp(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_timestamp(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timestamp(); ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() } -/// Returns the `Invoice`'s timestamp as a duration since the Unix epoch +/// Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch #[must_use] #[no_mangle] -pub extern "C" fn Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_since_epoch(); ret.as_secs() } @@ -2448,7 +2446,7 @@ pub extern "C" fn Invoice_duration_since_epoch(this_arg: &crate::lightning_invoi /// Returns the hash to which we will receive the preimage on completion of the payment #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_hash(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] { +pub extern "C" fn Bolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); ret.as_inner() } @@ -2458,7 +2456,7 @@ pub extern "C" fn Invoice_payment_hash(this_arg: &crate::lightning_invoice::Invo /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey { +pub extern "C" fn Bolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key(); let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; local_ret @@ -2467,7 +2465,7 @@ pub extern "C" fn Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Inv /// Get the payment secret if one was included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] { +pub extern "C" fn Bolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret(); &ret.0 } @@ -2475,7 +2473,7 @@ pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::In /// Get the payment metadata blob if one was included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { +pub extern "C" fn Bolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; local_ret @@ -2486,16 +2484,16 @@ pub extern "C" fn Invoice_payment_metadata(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Invoice_features(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning::ln::features::InvoiceFeatures { +pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } /// Recover the payee's public key (only to be used if none was included in the invoice) #[must_use] #[no_mangle] -pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey { +pub extern "C" fn Bolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key(); crate::c_types::PublicKey::from_rust(&ret) } @@ -2504,7 +2502,7 @@ pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invo /// Returning None if overflow occurred. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expires_at(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_DurationZ { +pub extern "C" fn Bolt11Invoice_expires_at(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_DurationZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expires_at(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_DurationZ::None } else { crate::c_types::derived::COption_DurationZ::Some( { ret.unwrap().as_secs() }) }; local_ret @@ -2513,7 +2511,7 @@ pub extern "C" fn Invoice_expires_at(this_arg: &crate::lightning_invoice::Invoic /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expiry_time(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time(); ret.as_secs() } @@ -2521,7 +2519,7 @@ pub extern "C" fn Invoice_expiry_time(this_arg: &crate::lightning_invoice::Invoi /// Returns whether the invoice has expired. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoice) -> bool { +pub extern "C" fn Bolt11Invoice_is_expired(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); ret } @@ -2529,7 +2527,7 @@ pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoic /// Returns the Duration remaining until the invoice expires. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_until_expiry(); ret.as_secs() } @@ -2538,7 +2536,7 @@ pub extern "C" fn Invoice_duration_until_expiry(this_arg: &crate::lightning_invo /// `time` is the timestamp as a duration since the Unix epoch. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Invoice, mut time: u64) -> u64 { +pub extern "C" fn Bolt11Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut time: u64) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiration_remaining_from_epoch(core::time::Duration::from_secs(time)); ret.as_secs() } @@ -2547,7 +2545,7 @@ pub extern "C" fn Invoice_expiration_remaining_from_epoch(this_arg: &crate::ligh /// `at_time` is the timestamp as a duration since the Unix epoch. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_would_expire(this_arg: &crate::lightning_invoice::Invoice, mut at_time: u64) -> bool { +pub extern "C" fn Bolt11Invoice_would_expire(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut at_time: u64) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.would_expire(core::time::Duration::from_secs(at_time)); ret } @@ -2556,7 +2554,7 @@ pub extern "C" fn Invoice_would_expire(this_arg: &crate::lightning_invoice::Invo /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`]. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta(); ret } @@ -2564,7 +2562,7 @@ pub extern "C" fn Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightnin /// Returns a list of all fallback addresses as [`Address`]es #[must_use] #[no_mangle] -pub extern "C" fn Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_AddressZ { +pub extern "C" fn Bolt11Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_AddressZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallback_addresses(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; local_ret.into() @@ -2573,7 +2571,7 @@ pub extern "C" fn Invoice_fallback_addresses(this_arg: &crate::lightning_invoice /// Returns a list of all routes included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_private_routes(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { +pub extern "C" fn Bolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); }; local_ret.into() @@ -2582,7 +2580,7 @@ pub extern "C" fn Invoice_private_routes(this_arg: &crate::lightning_invoice::In /// Returns a list of all routes included in the invoice as the underlying hints #[must_use] #[no_mangle] -pub extern "C" fn Invoice_route_hints(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_RouteHintZ { +pub extern "C" fn Bolt11Invoice_route_hints(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_RouteHintZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.route_hints(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() @@ -2591,7 +2589,7 @@ pub extern "C" fn Invoice_route_hints(this_arg: &crate::lightning_invoice::Invoi /// Returns the currency for which the invoice was issued #[must_use] #[no_mangle] -pub extern "C" fn Invoice_currency(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning_invoice::Currency { +pub extern "C" fn Bolt11Invoice_currency(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::Currency { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency(); crate::lightning_invoice::Currency::native_into(ret) } @@ -2599,7 +2597,7 @@ pub extern "C" fn Invoice_currency(this_arg: &crate::lightning_invoice::Invoice) /// Returns the amount if specified in the invoice as millisatoshis. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn Bolt11Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_u64Z { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_milli_satoshis(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; local_ret @@ -2674,7 +2672,7 @@ pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Errors that may occur when constructing a new [`RawInvoice`] or [`Invoice`] +/// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] #[derive(Clone)] #[must_use] #[repr(C)] @@ -2786,12 +2784,12 @@ pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str { alloc::format!("{}", &o.to_native()).into() } -/// Errors that may occur when converting a [`RawInvoice`] to an [`Invoice`]. They relate to the -/// requirements sections in BOLT #11 +/// Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to +/// the requirements sections in BOLT #11 #[derive(Clone)] #[must_use] #[repr(C)] -pub enum SemanticError { +pub enum Bolt11SemanticError { /// The invoice is missing the mandatory payment hash NoPaymentHash, /// The invoice has multiple payment hashes which isn't allowed @@ -2814,125 +2812,125 @@ pub enum SemanticError { /// The invoice's amount was not a whole number of millisatoshis ImpreciseAmount, } -use lightning_invoice::SemanticError as SemanticErrorImport; -pub(crate) type nativeSemanticError = SemanticErrorImport; +use lightning_invoice::Bolt11SemanticError as Bolt11SemanticErrorImport; +pub(crate) type nativeBolt11SemanticError = Bolt11SemanticErrorImport; -impl SemanticError { +impl Bolt11SemanticError { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeSemanticError { + pub(crate) fn to_native(&self) -> nativeBolt11SemanticError { match self { - SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, - SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, - SemanticError::NoDescription => nativeSemanticError::NoDescription, - SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, - SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret, - SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets, - SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures, - SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, - SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, - SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount, + Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash, + Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes, + Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription, + Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions, + Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret, + Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets, + Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures, + Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId, + Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature, + Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeSemanticError { + pub(crate) fn into_native(self) -> nativeBolt11SemanticError { match self { - SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, - SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, - SemanticError::NoDescription => nativeSemanticError::NoDescription, - SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, - SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret, - SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets, - SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures, - SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, - SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, - SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount, + Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash, + Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes, + Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription, + Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions, + Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret, + Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets, + Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures, + Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId, + Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature, + Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeSemanticError) -> Self { + pub(crate) fn from_native(native: &nativeBolt11SemanticError) -> Self { match native { - nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, - nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, - nativeSemanticError::NoDescription => SemanticError::NoDescription, - nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, - nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret, - nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets, - nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures, - nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, - nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, - nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount, + nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash, + nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes, + nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription, + nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions, + nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret, + nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets, + nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures, + nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId, + nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature, + nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeSemanticError) -> Self { + pub(crate) fn native_into(native: nativeBolt11SemanticError) -> Self { match native { - nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, - nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, - nativeSemanticError::NoDescription => SemanticError::NoDescription, - nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, - nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret, - nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets, - nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures, - nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, - nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, - nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount, + nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash, + nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes, + nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription, + nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions, + nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret, + nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets, + nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures, + nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId, + nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature, + nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount, } } } -/// Creates a copy of the SemanticError +/// Creates a copy of the Bolt11SemanticError #[no_mangle] -pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError { +pub extern "C" fn Bolt11SemanticError_clone(orig: &Bolt11SemanticError) -> Bolt11SemanticError { orig.clone() } #[no_mangle] -/// Utility method to constructs a new NoPaymentHash-variant SemanticError -pub extern "C" fn SemanticError_no_payment_hash() -> SemanticError { - SemanticError::NoPaymentHash} +/// Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_payment_hash() -> Bolt11SemanticError { + Bolt11SemanticError::NoPaymentHash} #[no_mangle] -/// Utility method to constructs a new MultiplePaymentHashes-variant SemanticError -pub extern "C" fn SemanticError_multiple_payment_hashes() -> SemanticError { - SemanticError::MultiplePaymentHashes} +/// Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_payment_hashes() -> Bolt11SemanticError { + Bolt11SemanticError::MultiplePaymentHashes} #[no_mangle] -/// Utility method to constructs a new NoDescription-variant SemanticError -pub extern "C" fn SemanticError_no_description() -> SemanticError { - SemanticError::NoDescription} +/// Utility method to constructs a new NoDescription-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_description() -> Bolt11SemanticError { + Bolt11SemanticError::NoDescription} #[no_mangle] -/// Utility method to constructs a new MultipleDescriptions-variant SemanticError -pub extern "C" fn SemanticError_multiple_descriptions() -> SemanticError { - SemanticError::MultipleDescriptions} +/// Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_descriptions() -> Bolt11SemanticError { + Bolt11SemanticError::MultipleDescriptions} #[no_mangle] -/// Utility method to constructs a new NoPaymentSecret-variant SemanticError -pub extern "C" fn SemanticError_no_payment_secret() -> SemanticError { - SemanticError::NoPaymentSecret} +/// Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_payment_secret() -> Bolt11SemanticError { + Bolt11SemanticError::NoPaymentSecret} #[no_mangle] -/// Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError -pub extern "C" fn SemanticError_multiple_payment_secrets() -> SemanticError { - SemanticError::MultiplePaymentSecrets} +/// Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_payment_secrets() -> Bolt11SemanticError { + Bolt11SemanticError::MultiplePaymentSecrets} #[no_mangle] -/// Utility method to constructs a new InvalidFeatures-variant SemanticError -pub extern "C" fn SemanticError_invalid_features() -> SemanticError { - SemanticError::InvalidFeatures} +/// Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_features() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidFeatures} #[no_mangle] -/// Utility method to constructs a new InvalidRecoveryId-variant SemanticError -pub extern "C" fn SemanticError_invalid_recovery_id() -> SemanticError { - SemanticError::InvalidRecoveryId} +/// Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_recovery_id() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidRecoveryId} #[no_mangle] -/// Utility method to constructs a new InvalidSignature-variant SemanticError -pub extern "C" fn SemanticError_invalid_signature() -> SemanticError { - SemanticError::InvalidSignature} +/// Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_signature() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidSignature} #[no_mangle] -/// Utility method to constructs a new ImpreciseAmount-variant SemanticError -pub extern "C" fn SemanticError_imprecise_amount() -> SemanticError { - SemanticError::ImpreciseAmount} -/// Checks if two SemanticErrors contain equal inner contents. +/// Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_imprecise_amount() -> Bolt11SemanticError { + Bolt11SemanticError::ImpreciseAmount} +/// Checks if two Bolt11SemanticErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool { +pub extern "C" fn Bolt11SemanticError_eq(a: &Bolt11SemanticError, b: &Bolt11SemanticError) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } #[no_mangle] -/// Get the string representation of a SemanticError object -pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str { +/// Get the string representation of a Bolt11SemanticError object +pub extern "C" fn Bolt11SemanticError_to_str(o: &crate::lightning_invoice::Bolt11SemanticError) -> Str { alloc::format!("{}", &o.to_native()).into() } /// When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] diff --git a/lightning-c-bindings/src/lightning_invoice/payment.rs b/lightning-c-bindings/src/lightning_invoice/payment.rs index 4c19e67..c3baa5c 100644 --- a/lightning-c-bindings/src/lightning_invoice/payment.rs +++ b/lightning-c-bindings/src/lightning_invoice/payment.rs @@ -16,66 +16,67 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -/// Pays the given [`Invoice`], retrying if needed based on [`Retry`]. +/// Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`]. /// -/// [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long -/// as the payment is still pending. Once the payment completes or fails, you must ensure that -/// a second payment with the same [`PaymentHash`] is never sent. +/// [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long +/// as the payment is still pending. If the payment succeeds, you must ensure that a second payment +/// with the same [`PaymentHash`] is never sent. /// /// If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`]. #[no_mangle] -pub extern "C" fn pay_invoice(invoice: &crate::lightning_invoice::Invoice, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_invoice::(invoice.get_native_ref(), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_invoice::(invoice.get_native_ref(), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`]. +/// Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on +/// [`Retry`]. /// /// Note that idempotency is only guaranteed as long as the payment is still pending. Once the /// payment completes or fails, no idempotency guarantees are made. /// -/// You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] -/// has never been paid before. +/// You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same +/// [`PaymentHash`] has never been paid before. /// /// See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token. #[no_mangle] -pub extern "C" fn pay_invoice_with_id(invoice: &crate::lightning_invoice::Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_invoice_with_id::(invoice.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_invoice_with_id(invoice: &crate::lightning_invoice::Bolt11Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_invoice_with_id::(invoice.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on +/// Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on /// [`Retry`]. /// -/// [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long -/// as the payment is still pending. Once the payment completes or fails, you must ensure that -/// a second payment with the same [`PaymentHash`] is never sent. +/// [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long +/// as the payment is still pending. If the payment succeeds, you must ensure that a second payment +/// with the same [`PaymentHash`] is never sent. /// /// If you wish to use a different payment idempotency token, see /// [`pay_zero_value_invoice_with_id`]. #[no_mangle] -pub extern "C" fn pay_zero_value_invoice(invoice: &crate::lightning_invoice::Invoice, mut amount_msats: u64, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_zero_value_invoice::(invoice.get_native_ref(), amount_msats, retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_zero_value_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msats: u64, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_zero_value_invoice::(invoice.get_native_ref(), amount_msats, retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key, -/// , retrying if needed based on [`Retry`]. +/// Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key, +/// retrying if needed based on [`Retry`]. /// /// Note that idempotency is only guaranteed as long as the payment is still pending. Once the /// payment completes or fails, no idempotency guarantees are made. /// -/// You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] -/// has never been paid before. +/// You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same +/// [`PaymentHash`] has never been paid before. /// /// See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the /// idempotency token. #[no_mangle] -pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invoice::Invoice, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_zero_value_invoice_with_id::(invoice.get_native_ref(), amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_zero_value_invoice_with_id::(invoice.get_native_ref(), amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } @@ -85,7 +86,7 @@ pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invo #[must_use] #[repr(C)] pub enum PaymentError { - /// An error resulting from the provided [`Invoice`] or payment hash. + /// An error resulting from the provided [`Bolt11Invoice`] or payment hash. Invoice( crate::c_types::Str), /// An error occurring when sending a payment. @@ -179,3 +180,9 @@ pub extern "C" fn PaymentError_invoice(a: crate::c_types::Str) -> PaymentError { pub extern "C" fn PaymentError_sending(a: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> PaymentError { PaymentError::Sending(a, ) } +/// Checks if two PaymentErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentError_eq(a: &PaymentError, b: &PaymentError) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs index e897a93..0b1f0bb 100644 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ b/lightning-c-bindings/src/lightning_invoice/utils.rs @@ -47,7 +47,7 @@ use alloc::{vec::Vec, boxed::Box}; /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// -/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager +/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -56,16 +56,14 @@ use alloc::{vec::Vec, boxed::Box}; /// /// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. -/// -/// Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_PaymentHashZ, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -78,9 +76,11 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// participating node /// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is /// updated when a channel becomes disabled or closes -/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice -/// may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared -/// down +/// * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum +/// of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected +/// in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node +/// until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as +/// desired, but note that some nodes will be trimmed if more than 3 nodes are provided. /// /// `description_hash` is a SHA-256 hash of the description text /// @@ -97,7 +97,7 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// -/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager +/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -105,16 +105,14 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// /// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. -/// -/// Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_PaymentHashZ, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -134,11 +132,11 @@ pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: cra /// /// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -159,11 +157,11 @@ pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lig /// /// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -171,11 +169,11 @@ pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(chann /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -183,11 +181,11 @@ pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_d /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -196,11 +194,11 @@ pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(ch /// This may be useful if you're building an on-chain swap or involving another protocol where /// the payment hash is also involved outside the scope of lightning. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning_persister.rs b/lightning-c-bindings/src/lightning_persister.rs index 5af129e..49ea879 100644 --- a/lightning-c-bindings/src/lightning_persister.rs +++ b/lightning-c-bindings/src/lightning_persister.rs @@ -109,7 +109,7 @@ pub extern "C" fn FilesystemPersister_get_data_dir(this_arg: &crate::lightning_p /// Read `ChannelMonitor`s from disk. #[must_use] #[no_mangle] -pub extern "C" fn FilesystemPersister_read_channelmonitors(this_arg: &crate::lightning_persister::FilesystemPersister, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, signer_provider: &crate::lightning::chain::keysinterface::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +pub extern "C" fn FilesystemPersister_read_channelmonitors(this_arg: &crate::lightning_persister::FilesystemPersister, mut entropy_source: crate::lightning::sign::EntropySource, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channelmonitors(entropy_source, signer_provider); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.into_inner() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs index 87b15b2..b4c2d51 100644 --- a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs +++ b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs @@ -141,6 +141,33 @@ pub extern "C" fn RapidGossipSync_new(network_graph: &crate::lightning::routing: crate::lightning_rapid_gossip_sync::RapidGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Sync gossip data from a file. +/// Returns the last sync timestamp to be used the next time rapid sync data is queried. +/// +/// `network_graph`: The network graph to apply the updates to +/// +/// `sync_path`: Path to the file where the gossip update data is located +/// +#[must_use] +#[no_mangle] +pub extern "C" fn RapidGossipSync_sync_network_graph_with_file_path(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut sync_path: crate::c_types::Str) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sync_network_graph_with_file_path(sync_path.into_str()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() }; + local_ret +} + +/// Update network graph from binary data. +/// Returns the last sync timestamp to be used the next time rapid sync data is queried. +/// +/// `update_data`: `&[u8]` binary stream that comprises the update data +#[must_use] +#[no_mangle] +pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut update_data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_network_graph(update_data.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() }; + local_ret +} + /// Update network graph from binary data. /// Returns the last sync timestamp to be used the next time rapid sync data is queried. ///